Click here to Skip to main content
16,013,082 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
well when i try to delete row data its give me Error "incorrect sysntax near 'cust_id'." please can any buddy sort out this problem




SQL
create table Customer 
(
cust_id numeric(10) not null,
cust_name nvarchar(max) not null,
cust_contact_no nvarchar(max) null,
cust_order_machine nvarchar(255) not null,
cust_order_date date null,
CONSTRAINT pk_CustomerID PRIMARY KEY (cust_id,cust_order_machine), 	
);


private void Button_Click(object sender, RoutedEventArgs e)
        {
            string dbconnection = (@"Data Source=EMIII-PC; Initial Catalog=gymdatabase;Integrated Security=True");
            SqlConnection conn = new SqlConnection(dbconnection);
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("DELETE FROM Customer" +  "WHERE cust_id = @id and cust_order_machine=@com" , conn);

                cmd.Parameters.AddWithValue("@id", textmidd.Text);

                cmd.Parameters.AddWithValue("@com", textcom.Text);

                
                
                
                cmd.ExecuteNonQuery();
                
            }

            catch (Exception ex)
            {

                MessageBox.Show(ex.Message.ToString());
            }

            finally
            {
                conn.Close();
               

            }
        }
Posted
Updated 10-Jul-14 15:50pm
v3

1 solution

change
C#
SqlCommand cmd = new SqlCommand("DELETE FROM Customer" +  "WHERE cust_id = @id and cust_order_machine=@com" , conn);

to
C#
SqlCommand cmd = new SqlCommand("DELETE FROM Customer WHERE cust_id = @id and cust_order_machine=@com" , conn);


you need space between Table name and Where
 
Share this answer
 
Comments
Member 10925486 11-Jul-14 6:03am    
thank you so much dear its work for me :)

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