Problem With Access connectin to VB.net

h0T

Member
Joined
Jun 21, 2004
Messages
15
Programming Experience
Beginner
hi dennis(h0t) can anyone guide or help me???
.... i created a design (blank)database with Microsoft Access n wanted to created a new database to save cust's details with Vb.net (runnin) so inside my microsoft access i got custid(primary key),custname,creditcardno.,no.ofnights,
so i used data wizard to create it ..
the connection i use is Microsoft Jet 4.0 OLE DB Provider
but i dont y when i refer the new record that i saved just now, it suddenly say error message about null value in custid??
????? ?????
 

bloukewer

Well-known member
Joined
Jul 2, 2004
Messages
88
Programming Experience
3-5
Bad encounters of the jet4 kind

If I understand you correctly, you are struggling to insert a new record into your database from your vb.net application.

If this is the case, I can say that I have also encountered this problem. I dont know why one can't change an oledbdata-adapter's querys's commandtexts (straightforwardly , anyway)...

The way I got past this problem is as follows...
1. I created the connection (eg. con1) as I normally do.
2. Create a String (eg. bstring) object, that contains a normal "INSERT"-sql statement. Use controls such as textboxes to build the string.
3. Create a OleDB-command object as follows (the following is pseudo-code) :

dim com1 as new OleDB.OleDBCommand(con1,bstring)

4. Execute the Insert-statement as follows (pseudo-code again) :

com1.ExecuteNonQuery()

5. Remember to close your connection when you have finished.

Hope this route works. It's the most direct I know of of solving this problem.
 
Top Bottom