Kingsley Simon

Kingsley Simon

  • NA
  • 13
  • 7.3k

Dataset Table Adapter Problem

Jan 15 2014 2:36 PM

Please I need help. 


I tried creating a TableAdapter with multiple queries using the steps shown in this link 

http://msdn.microsoft.com/en-us/library/ms171907(v=vs.110).aspx

But when I execute my query through my table adapter, it returns three columns instead of 1 column

This is the query 

SELECT StaffName
FROM Staff
WHERE (StaffID = @ID) AND (StaffPassword = @Password)

From the Query Builder, it is fine but from the TableAdapter it returns three columns )StaffID, StaffPassword and StaffName). The StaffID and StaffPassword is empty and the StaffName returns the correct value. 

How do I solve this?

Also, In my C# code, 

This code doesnt return any value to the Label3.Text. 

It should return the StaffName. 

How do I solve this?


private void button1_Click(object sender, EventArgs e)
{
int ID = Convert.ToInt32(textBox1.Text);
string Pswd = Convert.ToString(textBox2.Text);

TransportSystemDataSetTableAdapters.StaffTableAdapter s1 = new TransportSystemDataSetTableAdapters.StaffTableAdapter();
try
{
s1.ScalarQuery(transportSystemDataSet.Staff, ID, Pswd);

label3.Text = s1.ToString(); 
}

catch (SystemException)
{

}