IAm Creating a pRoject that uses visualbasic and m having difficulty storing data into the database m I created ......thqnks

Recommended Answers

All 5 Replies

What have you got so far?

Ok.....i Linked The 6forms i am using to A database using adodc and i used the code
A1Do
Private sub

PrVate sub 1command 1-click()
Adodc 1.recordset.addnew 
1AdodC 1.recordset.update

And command 1 is the "save "botton on the form

In order to add a record to a database you have to do an INSERT. Before you do that you have to establish a connection to the database and that requires a connection string which is specific to the type of database you are trying to connect to. For example, using MS SQL as the database you might do

con.Open("Driver={SQL Server};Server=.\SQLEXPRESS;Database=mydb;" & _
         "Trusted_Connection=yes;")
con.Execute("INSERT INTO myTable (id,name) VALUES(123,'Jim')")
con.Close()

ThaKs loads.....but i am using access(microsoft) as my database and i am also filling in the fields via textboxes....used adodc to connect the vb ti a database......also,i used the codes

Private sub frmlogin click()
Frmcreatenew.show
Unload me
Ifbtext 1=Vbnullstring and teXt 2=vbnullsting then
Msgbox"add new data" 
Else
Adodc 1.recordset .Addnew
End if
End sub

But the Ors
But the words i typed in the textbox then to overwrite therby making d code on l4liNe 4effective
Thanks

But the Ors
But the words i typed in the textbox then to overwrite therby making d code on l4liNe 4effective

I have no idea what you are saying. You didn't say in your OP what the back end database was. You'll have to pick an appropriate connection string for your version of Access. You can find it here

To use a query with values from a textbox you can creater a query string by concatenating values as in

qry = "INSERT INTO myTable (id,name) VALUES(" _
    & txtID.Text & ",'" & txtName.Text & "')"

or you can use a parameterized query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.