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)
{
}
Kingsley SimonPosted Jan 17, 2014, 8:01 AM
I hope im not disturbing you much.
As to my previous reply, the code is now working but in the event whereby the database is null, It doesnt retun "Incorrect Username or Password". It returns an error
"Input string was not in a correct format"
How do I solve this?
Kingsley SimonPosted Jan 17, 2014, 7:19 AM
I ended up doing this which was fine but when I changed to return StaffID which is an Int, it returns an error
{"Unable to cast object of type 'System.Int16' to type 'System.String'."}
How do I solve this problem?
Dhirendra MisraPosted Jan 16, 2014, 3:47 AM
Just wanted to know have you selected following option while building TableAdapter?
Step : 6 Choose the SELECT which returns a single value option, and then click Next.
You can get details :
http://msdn.microsoft.com/en-us/library/eeb84awz.aspx