Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Dim cmd1 As New SqlCommand("insert into users1(user_no,username,password,email,institname,institlisn,lisn_path,stutus,mobile,city,area,town,cord_x,cord_y,map_name,map_path)values(@user_no,@username,@password,@email,@institname,@institlisn,@lisn_path,@stutus,@mobile,@city,@area,@town,@cord_x,@cord_y,@map_name,@map_path)", conn)

Dim da As New SqlDataAdapter(cmd1)
Dim ds As New DataSet()
da.Fill(ds, "orders")
TextBox1.Text = ds.Tables("orders").Rows(i).Item(0).ToString
TextBox2.Text = ds.Tables("orders").Rows(i).Item(1).ToString
TextBox3.Text = ds.Tables("orders").Rows(i).Item(2).ToString
TextBox4.Text = ds.Tables("orders").Rows(i).Item(3).ToString
TextBox5.Text = ds.Tables("orders").Rows(i).Item(4).ToString
Image1.ImageUrl = ds.Tables("orders").Rows(i).Item(7).ToString
TextBox6.Text = ds.Tables("orders").Rows(i).Item(6).ToString
TextBox7.Text = ds.Tables("orders").Rows(i).Item(8).ToString
TextBox8.Text = ds.Tables("orders").Rows(i).Item(9).ToString
TextBox9.Text = ds.Tables("orders").Rows(i).Item(10).ToString
TextBox10.Text = ds.Tables("orders").Rows(i).Item(11).ToString
Image2.ImageUrl = ds.Tables("orders").Rows(i).Item(14).ToString



Session("user_no") = Val(TextBox1.Text)
cmd1.Parameters.Clear()
cmd1.Parameters.AddWithValue("@user_no", Session("user_no"))
cmd1.Parameters.AddWithValue("@username", TextBox2.Text)
cmd1.Parameters.AddWithValue("@password", TextBox3.Text)

cmd1.Parameters.AddWithValue("@email", TextBox5.Text)
cmd1.Parameters.AddWithValue("@institname", TextBox4.Text)
cmd1.Parameters.AddWithValue("@institlisn", Session("order_institlisn"))

cmd1.Parameters.AddWithValue("@lisn_path", Image1.ImageUrl)
cmd1.Parameters.AddWithValue("@stutus", "مشترك جديد")
cmd1.Parameters.AddWithValue("@mobile", TextBox7.Text)

cmd1.Parameters.AddWithValue("@city", TextBox8.Text)
cmd1.Parameters.AddWithValue("@area", TextBox9.Text)
cmd1.Parameters.AddWithValue("@town", TextBox10.Text)

cmd1.Parameters.AddWithValue("@cord_x", Session("@cord_x"))
cmd1.Parameters.AddWithValue("@cord_y", Session("@cord_y"))

cmd1.Parameters.AddWithValue("@map_name", Session("map_name"))
cmd1.Parameters.AddWithValue("@map_path", Image2.ImageUrl)

cmd1.ExecuteNonQuery()
conn.Close()
Posted
Updated 29-Jul-13 19:32pm
v2
Comments
Ankur\m/ 30-Jul-13 1:40am    
Did you check the query that was generated by SqlCommand object?

Change following query

VB
Dim cmd1 As New SqlCommand("insert into users1(user_no,username,password,email,institname,institlisn,lisn_path,stutus,mobile,city,area,town,cord_x,cord_y,map_name,map_path)values(@user_no,@username,@password,@email,@institname,@institlisn,@lisn_path,@stutus,@mobile,@city,@area,@town,@cord_x,@cord_y,@map_name,@map_path)", conn)


to below query

VB
Dim cmd1 As New SqlCommand("select user_no,username,password,email,institname,institlisn,lisn_path,stutus,mobile,city,area,town,cord_x,cord_y,map_name,map_path from users1", conn)
 
Share this answer
 
Replace these lines
VB
Session("user_no") = Val(TextBox1.Text)
cmd1.Parameters.Clear()
cmd1.Parameters.AddWithValue("@user_no", Session("user_no"))

with this one
VB
Session("user_no") = TextBox1.Text;
cmd1.Parameters.Clear()
cmd1.Parameters.AddWithValue("@user_no", TextBox1.Text)

Make sure that TextBox1.Text has value.

Regards..:laugh:
 
Share this answer
 
v2
Comments
ahmed200 30-Jul-13 1:51am    
the same problem

Must declare the scalar variable "@user_no".

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.SqlClient.SqlException: Must declare the scalar variable "@user_no".

Source Error:


Line 71: Dim da As New SqlDataAdapter(cmd1)
Line 72: Dim ds As New DataSet()
Line 73: da.Fill(ds, "orders")
Line 74: TextBox1.Text = ds.Tables("orders").Rows(i).Item(0).ToString
Line 75: TextBox2.Text = ds.Tables("orders").Rows(i).Item(1).ToString
Thanks7872 30-Jul-13 1:55am    
It simply mean that TextBox1.Text doesnt have any value. Put a breakpoint at the line

TextBox1.Text = ds.Tables("orders").Rows(i).Item(0).ToString

and see what happens.
ahmed200 30-Jul-13 17:52pm    
the same problem rohan leuva but the problem statement now is no row postion in 0
Thanks7872 31-Jul-13 0:07am    
It means that you are not getting any data. The problem is with
ds.Tables("orders").Rows(i).Item(0).ToString();

Rectify it and the problem will get solved.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900