When SqlCommandBuilder Just Doesn't Work

N

Neil B

Hi folks,

I have an odd one here. I'm trying to use SqlCommandBuilder to derive
the appropriate command objects in a SqlDataAdapter, but the
SqlCommandBuilder just doesn't seem to want to do its job. Code:

******
conn.Open();

SqlDataAdapter sqldata = new SqlDataAdapter("SELECT * FROM
TerminalList", conn);

SqlCommandBuilder sqlcmd = new SqlCommandBuilder(sqldata);
int rows = sqldata.Fill(terminallist, "TerminalList");
*******

Assume 'conn' is a valid SqlConnection (it is valid because the Fill()
call above works absolutely fine and returns the rows I expect it to).
No exceptions are firing during this operation. The underlying table has
a unique Primary Key.

My problem is that the SqlCommandBuilder is making no effort to generate
the INSERT, UPDATE, or DELETE commands that I would expect it to. All
those members remain undefined at the bottom of that code. Hence when I
try and call Update() on the SqlDataAdapter later-on, it except's
exactly as you'd expect it to ("You must have a valid UPDATE command
etc. etc.").

Any ideas?

Thanks in advance.

Neil B
 
N

Neil B

Please ignore. It looks like I made an incorrect assumption about when
the various SqlCommand members of SqlDataAdapter were actually filled in.

Move along. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top