I got the following error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
The source error is : MYcmd.ExecuteNonQuery()
Here is my Code: (Help me.....Thanks)
'========================================
Function addTeacherRecord(ByVal lName As String, ByVal fName As String)
' Change Data Source to the location of Northwind.mdb on your local
Dim sConStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data " _
& "Source=" & Server.MapPath("~/App_Data/students.mdb")
Dim password As String = generatePassword()
Dim userStatus As String
If statusList.SelectedIndex = 0 Then
userStatus = "Yes"
Else
userStatus = "No"
End If
Dim userProfile As String
If profileList.SelectedIndex = 0 Then
userProfile = "User"
Else
userProfile = "Admin"
End If
Dim user_name = fName + lName(0)
Dim mySQL As String = "INSERT INTO teachersTable (FirstName, LastName, UserName, Password, UserStatus,active) VALUES ('" & fName & "','" & lName & "','" & user_name & "','" & password & "','" & userProfile & "','" & 1 & "')"
Dim MyConn As New Data.OleDb.OleDbConnection(sConStr)
MyConn.Open()
Dim MYcmd As New Data.OleDb.OleDbCommand(mySQL, MyConn)
MYcmd.ExecuteNonQuery()
MyConn.Close()
newsLable1.Visible = True
newsLable2.Visible = True
newsLable2.Text = "הזנת הנתונים עבור " & fName & " " & lName & " הסתיימה בהצלחה."
userPassword1.Visible = True
userPassword1.Visible = True
userPassword1.Text = password
UserName2.Text = fName + lName(0)
Return 0
End Function
2 3175
Dear..
this is a simple error...
Dim mySQL As String = "INSERT INTO teachersTable (FirstName, LastName, UserName, Password, UserStatus,active) VALUES ('" & fName & "','" & lName & "','" & user_name & "','" & password & "','" & userProfile & "','" & 1 & "')"
here is where you went wrong ..
you can change it to
Dim mySQL As String = "INSERT INTO teachersTable (FirstName, LastName, UserName, Password, UserStatus,active) VALUES ('" & fName & "','" & lName & "','" & user_name & "','" & password & "','" & userProfile & "',1)"
happy coding
Thanks for the help
I a new error, it's: Expected query name after EXECUTE Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gérard Leclercq |
last post by:
ACCESS
First fields are TEXT, last 2 are Numbers
The name of the fields are correct.
Dim MyConn
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open...
|
by: dcarson |
last post by:
I've read about this error in several other discussions, but still
can't seem to pinpoint the problem with my code. Everything seemed to
be working fine for some time, but it now tends to bomb out...
|
by: William |
last post by:
i am using a dataset and a DataAdapter to update a table with the
following schema:
ResourceID
ProjectID
LastName
FirstName
Year
Nov
Dec
Jan
|
by: kosta |
last post by:
hello! one of my forms communicates with a database, and is
supposed to add a row to a table using an Insert
statement... however, I get a 'oledb - syntax error'
exception... I have double...
|
by: eric dugal |
last post by:
Hi all!!
I need your help.... i'm working since 2 hours on a simple insert statement,
but couldn't handle it.
Here is my code :
public int ExecQuery(string SqlString)
{
|
by: Neil Zanella |
last post by:
Hello,
I am trying to execute ADO.NET INSERT statement where one of the
fields
is coming from a password HTML control. When I access the text with
password.Value and print with Response.Write...
|
by: Nathan Sokalski |
last post by:
When trying to submit data to an Access database using ASP.NET I recieve the
following error:
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
+41...
|
by: amitbadgi |
last post by:
Hi guys, I am getting the following error in teh insert statement , I
am converting this asp application to asp.net, here is teh error,
Exception Details:...
|
by: RSH |
last post by:
I have a rather simple script that transfers data from a SQL server database
to an Access database. The procedure is intended to be dynamic so I am
basically adding a datarow and then passing the...
|
by: ewpatton |
last post by:
Good day,
I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |