O
ofiras
Is there a command to do a query for an SQL database?
I managed to make a sql connection variable, and to take info from it
by making a SqlDataAdapter with select query in it, and filling the
dataset with it.
If I want to do an insert query, I can't, because it is not saved in
the DB, and when I close the application I can't access it any more.
This is what I did:
SqlConnection cn = new SqlConnection();
SqlDataAdapter da;
cn = table1TableAdapter.Connection;
cn.Open();
da = new SqlDataAdapter("INSERT INTO Table1(item,title,cost)
VALUES('milk','low fat','100')",cn);
da.InsertCommand = da.SelectCommand;
da.Fill(myDBds, "Items");
cn.Close();
How do I query?
Please help,
Ofir.
I managed to make a sql connection variable, and to take info from it
by making a SqlDataAdapter with select query in it, and filling the
dataset with it.
If I want to do an insert query, I can't, because it is not saved in
the DB, and when I close the application I can't access it any more.
This is what I did:
SqlConnection cn = new SqlConnection();
SqlDataAdapter da;
cn = table1TableAdapter.Connection;
cn.Open();
da = new SqlDataAdapter("INSERT INTO Table1(item,title,cost)
VALUES('milk','low fat','100')",cn);
da.InsertCommand = da.SelectCommand;
da.Fill(myDBds, "Items");
cn.Close();
How do I query?
Please help,
Ofir.