Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-01-18 : 22:13:33
|
| I have the following code I am trying in C#.net'--------------------SqlConnection con = new SqlConnection("etc....") SqlDataAdapter adapter; DataSet ds; ds = new DataSet(); string query = "SELECT * FROM TEST"; adapter = new SqlDataAdapter(query,con); adapter.Fill(ds, "TEST"); string insertQuery = "THIS IS CRAP"; adapter.InsertCommand = new SqlCommand(insertQuery, con); adapter.Update(ds,"TEST"); '-----------------------------Why isnt an error produced when insertQuery is not a validSQL command? |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2005-01-19 : 12:09:53
|
| I'm sure if you try to insert records it will give you an error.-Chadhttp://www.clrsoft.comSoftware built for the Common Language Runtime. |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2005-01-19 : 12:29:15
|
| I think you need to add records to the data tables stored inside of the data set before you call your update method of the data adapter object.Dustin Michaels |
 |
|
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-01-20 : 18:21:52
|
| adapter.InsertCommand = new SqlCommand(insertQuery, con); Isnt this the insert |
 |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2005-01-21 : 11:45:24
|
| No. That is just setting the insert command of the DataAdapter to your bogus statement. Add some rows to the table, then try and update the database. It will fail.-Chadhttp://www.clrsoft.comSoftware built for the Common Language Runtime. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-21 : 11:47:01
|
you call the update/insert/delete with:DataSet ds = new DataSet();...ds.Update()Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|