Making connection to Access 2000

Mehyar, thankyou so much for you help. after all this time it finally worked. I really appreciate you taking so much time to help me out. I know where to come if I have any more questions.
Thanks Again
 
Wait, i do have another question :)
How difficult is it to explain how to move to the next record each time someone fills out the form. THanks
 
Sorry for that last post. The problem with with the database setting (i had my ID as number instead of autonumber so it wouldnt let me duplicate records) It works fine now.
THanks again
 
Hello,

I am having the same trouble to write something in a Access
file.

I am getting this error

An unhandled exception of type System.Data.OleDb.OleDbException occurred in system.data.dll

I created a connection exactly the same as stated above.

My access file contains 2 tables
1. Companyinformation
2. Configuration

within the Table Companyinformation Table I have 5 Fields
( company1,company2,company3,company4,company5)

I want to add "Hello" into the company1 field.

And this is my procedure

Public Sub write_info()
Dim command As New OleDbCommand
With command
.CommandText = "Insert into TableNAME (company1) values (" & txtcity.Text & ")"
.CommandText = "Insert into Companyinformation (company1) values (Hello)"

.Connection = connection1
End With

connection1.Open()
command.ExecuteNonQuery()
connection1.Close()
End Sub

What am I missing?

Thanks so much
 
hi mrdutchie,

try this.

Dim command As New OleDb.OleDbCommand()

command.CommandText = "insert into companyinformation (company1) values (@company1)"
command.Connection = oledb_connect

With command
.Parameters.Add("@company1", txtcity.Text.Trim)
End With
command.ExecuteNonQuery()
 
Tried it, but its failing on oledb_connect

if I leave that to connection1
then it looks like


Dim command As New OleDb.OleDbCommand

With command
.Parameters.Add("@company1", "Test")
.CommandText = "Insert into Companyinformation (company1) values (@company1)"
.Connection = connection1



End With
connection1.Open()
command.ExecuteNonQuery()
connection1.Close()

I need to have the open and Close statement in it

But still getting the same error.
Also tried to put the .Add on a different row
 
as your error says system.data.oldeexception, is the fields are of same type.

did you made the company1 varchar and the textbox.trim, sometimes the space values in the textbox may cause error.


if it is failing on ole_connect, your connection string is wrong, try to check the login and psswd and check the datasource.
 
Back
Top