| | |
revised but still not inserting (error near keyword "where")
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 34
Reputation:
Solved Threads: 0
I just keep getting the same error. can not insert record. Problem near keyword "where".
ASP.NET Syntax (Toggle Plain Text)
Imports System.Security Imports System.Data.SqlClient Imports System.Web.Configuration Imports System.Data Partial Class admin Inherits System.Web.UI.Page Public connectPath As String = ConfigurationSettings.AppSettings("Maya") Protected Sub fillDropList(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then DropList1.DataSource = Membership.GetAllUsers() DropList1.DataBind() End If End Sub Protected Sub DropList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropList1.SelectedIndexChanged Dim theUser2 As Integer = names.SelectedDataKey.Value Dim con As New SqlConnection con.ConnectionString = connectPath 'the customerID of the selected gridview row Dim setRep As New SqlCommand setRep.Connection = con setRep.CommandText = "INSERT INTO dbo.customers(rep)VALUES(@dropList1)WHERE customerID = @ID" setRep.Parameters.AddWithValue("@dropList1", DropList1.SelectedItem.ToString()) setRep.Parameters.AddWithValue("@ID", gridView1.SelectedDataKey.Value) Dim added As Integer = 0 Try con.Open() added = setRep.ExecuteNonQuery() results.Text = added.ToString() & "record has been added!" Catch Err As Exception results.Text = "Error inserting record. " results.Text &= Err.Message Finally con.Close() End Try End Sub End Class
•
•
Join Date: May 2008
Posts: 34
Reputation:
Solved Threads: 0
This is probably so simple but i just cant seen to figure it out. Im trying to insert the dropList1.selected.value into the column named "rep" in the dbo.customers table where customerID= the customer id of my gridview.
evidently there is a problem near key word "where" in my sql command text. Even when i try hard coding values such as
I still get an error. what am i doing wrong?????
thanks in advance
Rick Pace
evidently there is a problem near key word "where" in my sql command text. Even when i try hard coding values such as
ASP.NET Syntax (Toggle Plain Text)
INSERT INTO dbo.customers(rep) VALUES(some text) WHERE customerID = 48
I still get an error. what am i doing wrong?????
thanks in advance
Rick Pace
ASP.NET Syntax (Toggle Plain Text)
Dim setRep As New SqlCommand setRep.Connection = con setRep.CommandText = "INSERT INTO dbo.customers(rep)VALUES(@dropList1)WHERE customerID =@ID" setRep.Parameters.AddWithValue("@dropList1", DropList1.SelectedValue.ToString()) setRep.Parameters.AddWithValue("@ID", gridView1.SelectedDataKey.Value)
0
#3 29 Days Ago
Which error you get?? What is your CustomerID field? Does it autogenerated? If not then check that you may miss must have field values. Please post your error.
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
0
#4 29 Days Ago
That is invalid SQL and normally I would post the correct SQL but I have no clue what you're trying to do.
Valid SQL is simply:
Are you trying to
Valid SQL is simply:
sql Syntax (Toggle Plain Text)
INSERT INTO dbo.customers (col1, col2) VALUES (@val1, @val2)
Are you trying to
UPDATE the table instead of INSERT maybe? sql Syntax (Toggle Plain Text)
UPDATE dbo.Customers SET col1 = @val1, col2 = @val2 WHERE id = @id
Last edited by sknake; 29 Days Ago at 3:12 am.
0
#5 29 Days Ago
OHHHHH Yes please read basic concept on writing SQL. In Insert statement why where clause??
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
![]() |
Similar Threads
- google "keyword" question (Search Engine Optimization)
- error loading "Bridge.dll" (Windows 95 / 98 / Me)
- Error loading "C:\WINDOWS\ SYSTEM\BRIDGE.DLL' HELP (Windows 95 / 98 / Me)
- Hotmail "error on page" problem (Web Browsers)
Other Threads in the ASP.NET Forum
- Previous Thread: how to get the header name for the datatable in C#
- Next Thread: Pop up window on condition in asp.net 2.0
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






