I'm currently developing a Windows Form Application using C# and SQL server database.. I have a textbox on my form which has data in few lines and I wanted to store the data in SQL server database. Everything is working fine but the thing is I want to store each line of data into a separate row but I'm unable to do that. currently when I run a Program all the data is stored into a single row..
The code which I'm using is below..
Any help is appreciated.
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter sda;
DataSet ds = new DataSet();
string qry = "";
qry = "INSERT INTO [Example].[dbo].[SystemConsole1]([time],[Message])VALUES(GETDATE(),'" + rtTerminal.Text + "')";
con = new SqlConnection("Data Source=YOUR-0Z71CK0XVX\\SQLEXPRESS;Database=Example;Trusted_Connection=True");
cmd = new SqlCommand(qry, con);
if (con.State == ConnectionState.Open)
con.Close();
else
con.Open();
cmd.ExecuteNonQuery();
con.Close();
rtTerminal is the name of the Textbox where the data is present
MOD EDIT: please use the code tags
This post has been edited by eclipsed4utoo: 26 October 2010 - 04:40 AM

New Topic/Question
Reply




MultiQuote





|