| | | Forum Newbie
       
Group: Forum Members Last Login: 3/26/2010 4:39:21 AM Posts: 1, Visits: 2 |
| [
Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Users .... ") 'This here, declares where the database is located
Dim dt As New DataTable()
Dim str As String
Dim com As OleDb.OleDbCommand
Dim user_name As String = txtusername.Text
Dim pass_word As String = txtpassword.Text
'Dim application As String = txtapplication.Text
'try statement
Try
'declaration stage, declare all database components and strings
con.Open()
str = "insert into password(pass,username) values('" & pass_word & "','" & user_name & "')"
lblInfo.Text = "saved"
com = New Data.OleDb.OleDbCommand(str, con)
'execute the query
com.ExecuteNonQuery()
'close the connection
con.Close()
'if there is an error during the process ...
Catch ex As Exception
'warn the user that username is already taken
lblInfo.Text = "Username already exits. Please Try Another Username."
End Try
End Sub
/]
hi all, above is my code which is giving me some problems. actually im trying to insert into a MS ACCESS database, but for some reason im getting an error; Syntax error in INSERT INTO statement.
the thing is, when i paste the SQL statement into an SQL query it executes without any problems.
any help please?
please note im a bigginer 
thanks
mark
ow yeah im a bigginer
|
| | | | 
Forum God

Group: Moderators Last Login: 2/5/2012 6:29:46 PM Posts: 1,889, Visits: 5,254 |
| Welcome to A1vbcode zulli-mlt.  It won't sort your problem but it will make your code stand out more professional. Please use Mark's Syntax.zip when posting VB code in here. 
Keith
I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning. |
| |
|
|