Using SqlDataAdapter to run an INSERT query?

Smurfsdabomb

Member
Joined
Jan 10, 2009
Messages
10
Programming Experience
1-3
Hi, I'm moving over date.oledb commands to SQL ones and wondering what the equivalent to executenonquery here is?

This is what I have at the moment and I can bind select queries to datagrids no problem how would I get the DBCommand to execute the query?


Dim DBConn As SqlConnection
Dim DBCommand As SqlDataAdapter
Dim DSPageData As New DataSet

DBConn = New SqlConnection("Data Source=CIARAN-PC\SQLEXPRESS;Initial Catalog=Test1;Integrated Security=True;")
DBCommand = New SqlDataAdapter _
("INSERT into Login Values ('1', '2', '3', '4', '5') ", DBConn)
 
Add this:

VB.NET:
com = New SqlClient.SqlCommand
com.CommandType = CommandType.Text
com.CommandText = <sql command>
DBConn.Open()
com.ExecuteNonQuery()
DBConn.Close
 
Back
Top