C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




help is label


Posted Date: 11 Oct 2008      Total Responses: 1

Posted By: shashi booshan       Member Level: Bronze     Points: 1


Hi guys i want to display data in a label from the values retrieved from the database.
i have a textbox when user enters the "Login_Id" it shows the "Cust_Id" in a label.
but for me when i enter the "Login_Id" as "jackson12" it show an error message like "invalid colum jackson12".
donno wats happening.
pls help me guys.

this is my code
********************************************************************************
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Project_Airways;User Id=sa;Password=sql2005");
con.Open();
SqlCommand cmd = new SqlCommand("select Cust_Id from ARS_Cust_Reg where Login_Id = " + txt1.Text, con);
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
Label3.Text = dr["Cust_Id"].ToString();
Label3.Visible = true;
Label2.Visible = true;
con.Close();

}
catch (SqlException se)
{
Response.Write(se.Message);
}
finally
{
con.Close();
}
*******************************************************************************

thanks
regards
shashi




Responses

Author: Antony s Nasarath    11 Oct 2008Member Level: SilverRating:     Points: 4
Hi,

You have to pass the login id as a string ie text1.Text should be enclosed with single quote

Modify the line as follows
SqlCommand cmd = new SqlCommand("select Cust_Id from ARS_Cust_Reg where Login_Id = '" + txt1.Text +"'", con);

Regards,
Antony



Post Reply
You must Sign In to post a response.
Next : timer Control
Previous : Text Editor for text box
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use