943,967 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3072
  • C# RSS
Jun 27th, 2006
0

Problem in displaying returned value from function

Expand Post »
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.......
Last edited by Gowrishankar; Jun 27th, 2006 at 10:01 am.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Gowrishankar is offline Offline
13 posts
since Jun 2006
Jun 27th, 2006
0

Re: Problem in displaying returned value from function

LabelName.Text = StringName;
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 27th, 2006
0

Re: Problem in displaying returned value from function

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();
}
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Gowrishankar is offline Offline
13 posts
since Jun 2006
Jun 27th, 2006
0

Re: Problem in displaying returned value from function

here, let me clean up your code so that it more cleanly does what you have it doing now
C# Syntax (Toggle Plain Text)
  1. publicstring FuncAuthentication(string txtusername)
  2. {
  3. return "admin";
  4. }
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 28th, 2006
0

Re: Problem in displaying returned value from function

Hey,I want to get from the db not direct return.Hope you will have the ans...
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Gowrishankar is offline Offline
13 posts
since Jun 2006
Jun 28th, 2006
0

Re: Problem in displaying returned value from function

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"
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: New to C#. GDI driving me crazy!
Next Thread in C# Forum Timeline: SQLCommandBuilder is Dumb?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC