VB.NET & ExecuteNonQuery() The ExecuteNonQuery executes a Transact-SQL statement against the connection and returns the number of rows affected.
ShotDev Focus:
- VB.NET & ExecuteNonQuery()
Example
ExecuteNonQuery.aspx
<%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.OleDb"%> <%@ Page Language="VB" %> <script runat="server"> Dim objConn As System.Data.OleDb.OleDbConnection Dim objCmd As System.Data.OleDb.OleDbCommand Dim strConnString,strSQL As String strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;" objConn = New System.Data.OleDb.OleDbConnection(strConnString) objConn.Open() strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " & _ "VALUES ('C005','Weerachai Nukitram','webmaster@shotdev.com','TH','2000000','1000000')" objCmd = New System.Data.OleDb.OleDbCommand(strSQL,objConn) Try objCmd.ExecuteNonQuery() Catch ex As Exception lblText.Text = "Record Cannot Insert : Error (" & ex.Message & ")" End Try objCmd = Nothing objConn.Close() objConn = Nothing </script>