B
brett
I have a piece of code that i kinda hobbled together from examples i
found out on the net. I am wondering if i have some extra bits that i
don't necessarily need.
I have the following code:
Public Sub updatelog_table(ByVal [string] As String)
'*************** database **************
Using connection As New OleDbConnection(con)
Try
Dim command As New OleDbCommand("INSERT INTO
log([Note],DateAdded) VALUES ('" & [string] & "','" & Now() & "')")
command.Connection = connection
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error inserting records into log_Table: " &
ex.Message)
End Try
End Using
'*************** database ************
End Sub
"con" is a string variable defined elsewhere in the program. It
contains provider and data source info.
I am not explicitly using connection.close() anywhere and i am
wondering if the connection.open is required or if the
command.connection = connection bit does the same thing. I though
that by using the "using" statement it would dispose of the connection
when it was finished, but i have no idea.
Can anyone offer a few words on the subject?
Thanks,
Brett
found out on the net. I am wondering if i have some extra bits that i
don't necessarily need.
I have the following code:
Public Sub updatelog_table(ByVal [string] As String)
'*************** database **************
Using connection As New OleDbConnection(con)
Try
Dim command As New OleDbCommand("INSERT INTO
log([Note],DateAdded) VALUES ('" & [string] & "','" & Now() & "')")
command.Connection = connection
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error inserting records into log_Table: " &
ex.Message)
End Try
End Using
'*************** database ************
End Sub
"con" is a string variable defined elsewhere in the program. It
contains provider and data source info.
I am not explicitly using connection.close() anywhere and i am
wondering if the connection.open is required or if the
command.connection = connection bit does the same thing. I though
that by using the "using" statement it would dispose of the connection
when it was finished, but i have no idea.
Can anyone offer a few words on the subject?
Thanks,
Brett