Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format of the initialization string does not conform to specification starting at index 0. 1

Status
Not open for further replies.

faxpay

Programmer
Nov 30, 2004
119
US


Below is my code. Getting Argument Exception(see subject) at "Using connection....." line. Looks like the connectionString is causing it but I can't see anything wrong with the string. This is the string: "C:\T&NDevelop\EFTPS_Access_TestSQL__App.vbp\database6.accdb\"
Where might I look?

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

Tom
tnfaxpay
 
Seems your code is more VB.NET than VBA ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi Tom,

two things:
a) For VB.Net questions, post here: forum796
b) Your connection string is not a connection string, only the path to a db.

For a proper connection string, see here:
and put your path to the accdb in the "Data Source" part.

Good luck!
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Hi MakeItSo,

Stupid mistake! The obvious is many times not so obvious.

Thank You,
Tom
tnfaxpay

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top