By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,112 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

How to add a new record into the table?

P: n/a
I want to add a new record (i.e. new vendor) into the
table. I have tried using the Insert Command but it
doesn't insert the record into the SQL table. Or is there
any other ways to add a new record? Below are the codes
that I have typed in.

--- Codes ---

cmdInsert.CommandText = "Insert INTO " _
& "tblVendors(VendorID)" _
& "VALUES(@VendorID)"
cmdInsert.Parameters.Add("@VendorID", SqlDbType.Int, 4,
txtVendorID.Text)

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Probably a dumb question - but did you call cmInsert.ExecuteNonQuery() after
adding the parameters?

Imran.

"Neuxs" <an*******@discussions.microsoft.com> wrote in message
news:3f****************************@phx.gbl...
I want to add a new record (i.e. new vendor) into the
table. I have tried using the Insert Command but it
doesn't insert the record into the SQL table. Or is there
any other ways to add a new record? Below are the codes
that I have typed in.

--- Codes ---

cmdInsert.CommandText = "Insert INTO " _
& "tblVendors(VendorID)" _
& "VALUES(@VendorID)"
cmdInsert.Parameters.Add("@VendorID", SqlDbType.Int, 4,
txtVendorID.Text)

Nov 21 '05 #2

P: n/a
If I use ExecuteNonQuery, I would need to have a connection string to the
server right? I'm currently using the OleDbDataAdpater and
OleDbDataConnection to make my connection...
"Imran Koradia" wrote:
Probably a dumb question - but did you call cmInsert.ExecuteNonQuery() after
adding the parameters?

Imran.

"Neuxs" <an*******@discussions.microsoft.com> wrote in message
news:3f****************************@phx.gbl...
I want to add a new record (i.e. new vendor) into the
table. I have tried using the Insert Command but it
doesn't insert the record into the SQL table. Or is there
any other ways to add a new record? Below are the codes
that I have typed in.

--- Codes ---

cmdInsert.CommandText = "Insert INTO " _
& "tblVendors(VendorID)" _
& "VALUES(@VendorID)"
cmdInsert.Parameters.Add("@VendorID", SqlDbType.Int, 4,
txtVendorID.Text)


Nov 21 '05 #3

P: n/a

"Nexus" <Ne***@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
If I use ExecuteNonQuery, I would need to have a connection string to the
server right? I'm currently using the OleDbDataAdpater and
OleDbDataConnection to make my connection...


Don't you already have a connection with a connection string? You shouldn't
need the OleDbDataAdapter just to insert data into the database. You just
need to call cmdInsert.ExecuteNonQuery.

Imran.
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.