954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem in displaying returned value from function

Hi,I am having problem in displaying the returned value from one function.I write one function for creating db connection,in that function I returned the string value of username.I want to display the string username value in different label through a button click event.What is the C# ASP.NET syntax ?Can any one help me..?Thanks.......

Gowrishankar
Newbie Poster
13 posts since Jun 2006
Reputation Points: 10
Solved Threads: 1
 

LabelName.Text = StringName;

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

Hi,You gave one syntax know,that is not working, Again I have some error...So,I discribed my problem here again ....
In that function I return one string value,I want to display the string value in another project by calling the dll of this.How can I display..?
Could you tell the code is correct or not for creating the db connection ?

publicstring FuncAuthentication(string txtusername)
{
string conn ="server=IDC-DEVELOPMENT ;uid=sa;pwd=password;database=SCBNotis";
string comm = "Select ADMINUSERID from ADMIN where ADMINUSERID='admin'";
SqlDataAdapter da =new SqlDataAdapter(comm,conn);
DataSet ds = new DataSet();
da.Fill(ds,"ADMIN");
DataTable dt = ds.Tables[0];
DataView dv;
dv = ds.Tables[0].DefaultView;
foreach(DataRow dr in dt.Rows)
{
txtusername=(dr [ "ADMINUSERID" ].ToString ( ));}
return txtusername.ToString();
}

Gowrishankar
Newbie Poster
13 posts since Jun 2006
Reputation Points: 10
Solved Threads: 1
 

here, let me clean up your code so that it more cleanly does what you have it doing now

publicstring FuncAuthentication(string txtusername)
{
return "admin";
}
campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

Hey,I want to get from the db not direct return.Hope you will have the ans...

Gowrishankar
Newbie Poster
13 posts since Jun 2006
Reputation Points: 10
Solved Threads: 1
 

you're missing the point, which is that you're sql query isn't going to work.
It is always going to return either null or "admin"

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You