Team-BHP > Shifting gears > Gadgets, Computers & Software
Register New Topics New Posts Top Thanked Team-BHP FAQ


Reply
  Search this Thread
1,937 views
Old 22nd May 2008, 09:41   #1
Senior - BHPian
 
mjothi's Avatar
 
Join Date: Dec 2007
Location: Bangalore
Posts: 3,287
Thanked: 231 Times
Clarification on .NET (VB 2005 Express edition)

I am trying to create a program to insert / update records in MS Access DB. I tried to check the MSDN, forums and somehow getting there. It looks so easy, but tough. I get strange error when I execute the connection.open command :(
The error I get is
"A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll"
Below is the function.

Public Sub InsertRow(ByVal connectionString As String, _
ByVal insertSQL As String)
Using connection As New OleDbConnection(connectionString)
' The insertSQL string contains a SQL statement that
' inserts a new row in the source table.
Dim command As New OleDbCommand(insertSQL)

' Set the Connection to the new OleDbConnection.
command.Connection = connection

' Open the connection and execute the insert command.
Try
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
' The connection is automatically closed when the
' code exits the Using block.
End Using
End Sub

Any helps?
mjothi is offline  
Old 22nd May 2008, 11:14   #2
Senior - BHPian
 
NetfreakBombay's Avatar
 
Join Date: Jan 2008
Location: Bombay
Posts: 1,466
Thanked: 1,021 Times

What is the value of connection string? Are you using a DSN?
NetfreakBombay is offline  
Reply

Most Viewed


Copyright ©2000 - 2024, Team-BHP.com
Proudly powered by E2E Networks