Re: Insert Data



This is my function for executing UPDATE, INSERT and DELETE commands on
a database. You just supply the SQL statement and the connection
string and then execute the function.

Public Function ExecDB(ByVal ExecuteQuery As String, ByVal
ConnectionString As String) As Boolean
' This function takes in a execute statement and a database
connection
' string and will execute the statement on the database and
report true/false
' if it executed properly or not

Try
Dim oleConn As New OleDbConnection(ConnectionString)
Dim oleCmd As New OleDbCommand(ExecuteQuery, oleConn)
oleCmd.Connection.Open()
oleCmd.ExecuteNonQuery()
oleConn.Close()
oleCmd.Dispose()
Return True
Catch ex As Exception
MessageBox.Show("Database Error:" & Chr(10) & ex.Message)
Return False
End Try
End Function

.



Relevant Pages

  • Re: Multiple Tables SELECT command with Microsoft Access 2003
    ... need to delimit it with single quotes so it can be treated as a string ... The issue I have is that when I try and execute this sql statement use ... // create the connection ... OleDbConnection dbcx = new ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Multiple Tables SELECT command with Microsoft Access 2003
    ... or a string? ... The issue I have is that when I try and execute this sql statement use ... // create the connection ... OleDbConnection dbcx = new ...
    (microsoft.public.dotnet.framework.adonet)
  • SQLConnection
    ... executing each sql statement I am opening the connection, ... closing sqlreader and closing the connection. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: executing sproc
    ... Issue is resolved by adding Initialization string to DSN. ... for the stored proc but not for the SQL statement. ... > establish a new Connection Cnct and open it successfully. ...
    (microsoft.public.data.ado)
  • Re: SQLConnection
    ... Using the same connection in multiple threads is not supported. ... > executing each sql statement I am opening the connection, ... closing sqlreader and closing the connection. ...
    (microsoft.public.dotnet.framework.adonet)