a simple question

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I have a simple question here,

ConnectToDB();

string queryString = "SELECT Owner,Description FROM Groups WHERE Title =
'BOSS'";

MySqlCommand myCmd = new MySqlCommand(queryString,mycon);

try
{
lblOwner.Text = (string)myCmd.ExecuteScalar();
}
finally
{
myCmd.Dispose();
mycon.Dispose();
}

it's only get one(Owner) value back, so what I need to do so I can pull both
Owner and Description from database?

Thansk in advance.
 
Hi Jason,

ExecuteScalar method always returns only one value, not multiple values for
one row. You would need to use ExecuteReader to get an access to all the
fields in a row
 
hello...

i think u can achieve the same by using datasets...ie
instead of calling....executescalar...use a dataadapter and user
dataadapter.fill(datasetname)...

ur datatable will have that row with 2 columns ...

hope this will help u.../

smiles,
Laiju
 
Jason,

As an alternative to the answers from Val and Laiju,
Use two selectsstrings and two executescalars.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top