Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Insert Statment Error


Insert Statment Error

Author
Message
zulli-mlt
zulli-mlt
Forum God
Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)Forum God (373 reputation)

Group: Forum Members
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 Smile



thanks

mark

ow yeah im a bigginer

Keithuk
Keithuk
Forum God
Forum God (297K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K
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. Wink

Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search