|
-
Nov 21st, 2008, 10:07 PM
#1
Thread Starter
Member
Insert text from text box to access db
I am having trouble getting the program to actually insert a string from a textbox to an access db. Below is my code. I have a total of 4 tables, and am wanting to insert into the table titled ticket. I am wanting to insert into a field titled ID. I am trying to learn this for school, but the books the school uses doesn't cover this at all. All help is appreciated.
Public Sub insert()
Dim da As DataSet
Dim command As OleDbCommand
Dim sql As String = "select ticket from ticket"
Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\Chris\Documents\Visual Studio 2008\Projects\WindowsApplication3\WindowsApplication3\bin\Debug\ETUO1.accdb;")
con.Open()
Dim SQLstr As String
Dim dp As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("Insert into Ticket", con)
SQLstr = String.Format("INSERT INTO TableTicket VALUES('{0}')", txtNumber.Text)
command = New OleDbCommand(SQLstr, con)
MessageBox.Show("works")
con.Close()
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|