Link to home
Start Free TrialLog in
Avatar of chokka
chokkaFlag for United States of America

asked on

ExecuteNonQuery() MS Access


VS 2005 / VB.Net
Simple Insert Query.

Using Execute Non Query -


I am not able to insert a simple query.

Table has only two columns ( StatesId which is AutoNumber and StateShortName which is Text DataType ).

Dim myOleCommand As OleDbCommand
Dim myConn As New OleDbConnection("C:\Enrollment Form\EnrollmentApp\EnrollmentApp\EnrollmentDB.mdb")

myConn.Open()
Dim strCommand As String
strCommand = "Insert into tmpStates (StateShortName) values('Chokka')"
myOleCommand = New OleDbCommand(strCommand, myConn)
myOleCommand.ExecuteNonQuery()
myConn.Close()

Open in new window

Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Do you get any errors ?

try
   myConn.Open()
   Dim strCommand As String
   strCommand = "Insert into tmpStates (StateShortName) values('Chokka')"
   myOleCommand = New OleDbCommand(strCommand, myConn)
   myOleCommand.ExecuteNonQuery()
   myConn.Close()
catch ex as Exception

end try
Avatar of chokka

ASKER

No, I am not getting any errors
Avatar of chokka

ASKER

I am not getting any errors and Insertion is not happeing ..
Avatar of chokka

ASKER

Once i closed the app and opened again, i am getting errors as follows

{"Format of the initialization string does not conform to specification starting at index 0."}
{"Format of the initialization string does not conform to specification starting at index 0."}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chokka

ASKER

Thanks Dhaest:

It works ..!

Now, i need to move this connection string to App.Config file ..!