Welcome to Dream.In.Code
Become a VB Expert!

Join 149,921 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,979 people online right now. Registration is fast and FREE... Join Now!




trouble with update code

 
Reply to this topicStart new topic

trouble with update code

didgy58
5 Jan, 2008 - 05:26 AM
Post #1

D.I.C Head
**

Joined: 23 Oct, 2007
Posts: 217



Thanked: 1 times
My Contributions
alright guys and gals

i have a basic program that is displaying records from a database, easy the prev and next buttons work fine, when i go to add a user it throws out errors
it says in the additional information there is a syntax error in INSERT INTO statment

the code looks like this

CODE


if inc <>-1 then
dim cb as new oledb.oledbcommandbuilder(da)
dim dsnewrows as dataraw
dsnewrows=ds.tables ("users").NewRow()

dsnewrows.item(0)=txtuser.text
dsnewrows.item(1) = txtpass.text
dsnewrows.item(2) = txtadmin.text

ds.tables("users").Rows.Add(dsnewrows)
da.update(ds, "users")
msgbox ("user added to the database")
end if



the database connection is fin the database has 3 fields

user name
pass
admin level

this code is executed on the commit changes to database button so when they have filled in the details it then does this

i also have the same problem with the edit facility as well that says the same error message

un unhandled exception of type system.data.oledb.oledbexception occured in system.data.dll

error in update statment

the code in the update looks like this

CODE


dim cb as new ole.oledbcommandbuilder(da)

ds.tables("users").rows(inc).item(0) =txtuser.text
ds.tables("users").rows(inc).item(1) =txtpass.text
ds.tables("users").rows(inc).item(2) =txtadmin.text

da.update(ds, "users")
msgbox("record updated")


on load of the form the da is set as follows

CODE


da=new oledb.oledbdataadapter(sql, con)
da.fill(ds, "users")

maxrows=ds.tables("users").rows.count
inc=-1



if there is anybody out there who could help me i would be very greatfull, i understand how to put records in with mysql statments but i dont see how you would build a insert statment. could i just do something like that.

thanks

dan
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 02:50PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month