Home All Groups Group Topic Archive Search About

Newbie: Examples of ExecuteNonQuery

Author
21 Apr 2006 6:04 PM
Parasyke
Does anyone have any examples of "ExecuteNonQuery"? I've tried to grap
this phrase but examples may be my only way of understanding this
concept. Any real-world code snipits with a brief description would be
so kind.

Thanks!

Author
21 Apr 2006 6:53 PM
MickyM
You would use that for something that was going to execute but not
return anything (like an Update, Insert, or Delete statement)

Thanks,
Mick
Author
22 Apr 2006 5:09 AM
Earl
I've cut out the error handling and input validation code so you can see the
idea clearly. Use when you do not need a return value (such as an Insert).

Public Sub AddNewCustomer()
Dim strSQLServer As New SqlConnection(strConn)

Dim cmd As New SqlCommand("CustomerInsert", strSQLServer)
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = strSQLServer

cmd.Parameters.Add(New SqlParameter("@Honorific", SqlDbType.VarChar, 10))
cmd.Parameters.Item(0).Value = txtSal.Text

cmd.Parameters.Add(New SqlParameter("@FirstName", SqlDbType.VarChar, 50))
cmd.Parameters.Item(1).Value = txtFirstName.Text

cmd.Parameters.Add(New SqlParameter("@LastName", SqlDbType.VarChar, 50))
cmd.Parameters.Item(2).Value = txtLastName.Text

strSQLServer.Open()
cmd.ExecuteNonQuery()

strSQLServer.Close()
End Sub

Show quoteHide quote
"Parasyke" <kress1963no***@yahoo.com> wrote in message
news:1145642671.297157.82910@i40g2000cwc.googlegroups.com...
> Does anyone have any examples of "ExecuteNonQuery"? I've tried to grap
> this phrase but examples may be my only way of understanding this
> concept. Any real-world code snipits with a brief description would be
> so kind.
>
> Thanks!
>