Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to write a query to select data from db in condition i want to use textbox1.text how can i do this??
in favor of multy time using of this query i want to write witoth Qcommand.Parameters.AddWithValu command.
my code is:
C#
string commandText = "select id from moshtari where mobile="+ textBox3.Text;
               
                Qcommand.CommandText = commandText;
                Qcommand.CommandType = CommandType.Text;
                object k = Qcommand.ExecuteScalar();

with this i see error.
Posted

Write Like-
C#
string commandText = "select id from moshtari where mobile=@mobileno;
Qcommand.Parameters.AddWithValue("@mobileno",Textbox3.Text);
 
Share this answer
 
v2
C#
Qcommand.Parameters.AddWithValue("mobile",textbox3.Text);
 
Share this answer
 

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