- Private Sub Button_Submit_Click(sender As System.Object, e As System.EventArgs) Handles Button_Submit.Click
-
Submit.Submit()
-
-
Dim Connection As New OleDbConnection(_conString)
-
Dim DataReader As OleDbDataReader
-
Dim Command As New OleDbCommand
-
Dim Query As String
-
-
Connection.Open()
-
-
Query = "INSERT INTO LOGIN(user_name, password, user_type, firstname, lastname, email, address) values ( ?,?,?,?,?,?,?)"
-
-
-
'Command.Connection = Connection
-
'Command.CommandText = Query
-
-
DataReader = Command.ExecuteReader()
-
-
Command.Parameters.AddWithValue("User_Name", TextBox_UserName.Text)
-
Command.Parameters.AddWithValue("Password", TextBox_Password.Text)
-
Command.Parameters.AddWithValue("User_Type", TextBox_Usertype.Text)
-
Command.Parameters.AddWithValue("FirstName", TextBox_FirstName.Text)
-
Command.Parameters.AddWithValue("LastName", TextBox_LastName.Text)
-
Command.Parameters.AddWithValue("Email", TextBox_Email.Text)
-
Command.Parameters.AddWithValue("Address", TextBox_Address.Text)
-
-
'Command.ExecuteNonQuery()
-
-
MessageBox.Show("Added Successful")
-
-
Try
-
Catch ex As Exception
-
MessageBox.Show(ex.Message)
-
Finally
-
Connection.Close()
-
-
-
End Try
-
End Sub
-
-
End Class
4 1161
You gave your parameters a name but you didn't use those names in the SQL query. You should also start your parameter names with @
Which parameters names? They all look they same to me. What do you mean?
Line 11, you use ? to designate your variables. But then you add parameters with names on lines 19-25. The query has no idea which of those names matches up with the question marks. Just because you gave the parameter the same name as a field in the table doesn't mean the engine knows to translate that into the same location in the SQL. You need to use the parameter names in the SQL itself and you need to start your parameter names with the @ symbol.
Hey jsand03z, you have to use like as follows...
Replace line number 11 with the following code... - Query = "INSERT INTO LOGIN(user_name, password, user_type, firstname, lastname, email, address) values (@User_Name, @Password, @User_Type, @FirstName, @LastName, @Email, @Address)"
Then replace line number 19 to 25 with the following codes... - Command.Parameters.AddWithValue("@User_Name", TextBox_UserName.Text)
-
Command.Parameters.AddWithValue("@Password", TextBox_Password.Text)
-
Command.Parameters.AddWithValue("@User_Type", TextBox_Usertype.Text)
-
Command.Parameters.AddWithValue("@FirstName", TextBox_FirstName.Text)
-
Command.Parameters.AddWithValue("@LastName", TextBox_LastName.Text)
-
Command.Parameters.AddWithValue("@Email", TextBox_Email.Text)
-
Command.Parameters.AddWithValue("@Address", TextBox_Address.Text)
Check your code again you misplaced "Try" (It should be placed before line number 9 in your code).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: soni29 |
last post by:
hi,
i have a small question regarding sql, there are two tables that i
need to work with on this, one has fields like:
Table1:
(id, name, street, city, zip, phone, fax, etc...) about 20 more...
|
by: Curt Morrison |
last post by:
I have an ASP login section on my site that is experiencing some problems.
Go to the following page and create a fake account (this is a test
environment, so don't worry):
...
|
by: Mike |
last post by:
I know this sounds strange but I am at a loss. I am calling a simple
funtion that opens a connection to a SQL Server 2000 database and executes
an Insert Statement.
private void...
|
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: Paul Mason |
last post by:
Hi folks,
The ado.net stream appears to be not working so I'm here.
The following function generates the error "Operation must use an updateable
query". There is no identifiable or meaningful...
|
by: glenn |
last post by:
Hi folks,
I am using an Access database, VB.NET and ADO.NET working with a DataGrid
control.
MY datagrid table has both a date_sent and a date_ans field. When I Insert
a record in my SQL...
|
by: rhaazy |
last post by:
Using ms sql 2000
I have 2 tables.
I have a table which has information regarding a computer scan. Each
record in this table has a column called MAC which is the unique ID for
each Scan. The...
|
by: Good Guy |
last post by:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Customers_Contact".
The conflict occurred in database "BreakAway", table "dbo.Contact", column 'ContactID'.
The statement has...
|
by: Billie Hartline |
last post by:
I am an untrained Volunteer assisting a non-profit organization
What I am attempting to do is Select the Max(ID) following an Insert into the database. Then pass the MaxID to a second page and...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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: 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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |