Re: Write to Sql DataBase
Search bing or google for "SqlConnection SqlDataAdapter writing to a database".
You will be rewarded with mucho code samples.
Re: Write to Sql DataBase
okay i searched bing and i am working on this one tutorial that seems to have good information on it. i got this error that says my login failed. well i see why it didnt use my sql authentication that was meant to be used. how do i set the login to be SQL not Windows?
Re: Write to Sql DataBase
okay that tutorial showed me how to fix that error now i have error 0: saying that no process is on the other end of the pipe? what does that mean?
Re: Write to Sql DataBase
What connection string are you using?
Re: Write to Sql DataBase
i am not sure. it started throwing error 26: again.
here is the code used for the connection. it all happens when you click the CheckOut button
Code:
private void btnCheckOut_Click(object sender, EventArgs e)
{
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = "user id=jsitz1469;" + "password=labR2o6;" + "Trusted_Connection=yes;" + "Data Source=TNIXON-PC-05\\SITZ;";
try
{
dataConnection.Open();
}
finally
{
dataConnection.Close();
}
}
what am i doing wrong? and how do i select the database i want to use. 'SITZ' is just the name of the Instance i need to select a particular database from within that instance.
Re: Write to Sql DataBase
Check out the following site for db connection strings:
http://www.connectionstrings.com/
Re: Write to Sql DataBase
ahhhhhh i cant get it to connect now. i get error: 40 - could no open a conneciton to SQL Server
here is the connection string
Code:
dataConnection.ConnectionString = "user id=jsitz1469;" + "password=labR2o6;" + "Data Source=TNIXON-PC-05\\SITZ;" + "Initial Catalog=CheckInCheckOut;" + "Integrated Security=true;";
and i know i know dont hard code log in information into the application but i am working on getting connected before i start encrypting the information
Re: Write to Sql DataBase
You use a trusted connection OR login info (userID/password) ... but NOT both... if you are trying to use a SQL Login... drop the TrustedConnection=True from your connection string. By using it and setting it to True, you're saying that you want to use Windows Login.
-tg
Re: Write to Sql DataBase
oh,
that makes sense, thank you TechGnome. that allowed for my connection to become valid i think. it doesnt throw an error when i click the button associated with the connection. so i am assuming that the connection at this point is opened and then closed. now i need to write some string values to the database. this is the tricky part though isnt it?