| | |
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 Oct 29th, 2009
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 Oct 29th, 2009
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; Oct 29th, 2009 at 3:12 am.
0
#5 Oct 29th, 2009
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 2.0 3.5 activexcontrol advice ajax appliances asp asp.net beginner bottomasp.net box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv form forms gridview gudi homeedition hosting iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings redirect registration relationaldatabases rotatepage search security select serializesmo.table sessionvariables silverlight smartcard sql ssl tracking treeview typeof validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopment wizard xml xsl






