Sumit Dwivedi

Sumit Dwivedi

  • NA
  • 8
  • 2.3k

ADO.Net connection in C#

Nov 3 2015 9:54 AM
 Hi Friends,
 
After making the ADO.Net connection, when i am trying to fetch the s_name value based on the input from textbox using below query. I am getting object reference null error. Can anybody identify what actually is the flaw in the below code
 
string @searchValue = txtStudentName.Text;
 
string sql = "SELECT * FROM Student_Detail where s_name=@searchValue"; 
 
No record is coming in sql object.
 
  SqlCommand cmd = new SqlCommand(sql, connection); 

Answers (5)