You did not provide enough information about your issue.
Does the reader contains anything? No! Have a look at your query:
"select * from JUNIOR_STUDENT where @UID='+ @ " + txtUid.Text.Trim() + "'"
Your query should be:
select [Name], RollNo, Stream, Gender, Year_ID, Remarks, Admission_Date, Academic_Year, Admission_tye, Category_ID, Sub_Category
from JUNIOR_STUDENT
where UID=@UID
Finally, you are using only ine parameter
@UID
, so why do you set
[Name]
,
Rollno
, etc?
BTW: Name is a reserved word, use it with brackets!
Corrected code:
SqlCommand cmd = new SqlCommand("select * from JUNIOR_STUDENT where UDI=@UID",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UId", txtUid.Text);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
Here is a basic idea:
HOW TO: Call SQL Server Stored Procedures in ASP.NET by Using Visual C# .NET[
^]. It's true, it's ASP.NET, but the logic is the same!