Building ADO.net Connected ASP.Net page with C#

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
Mechano
Registered User
Posts: 291
Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:

Building ADO.net Connected ASP.Net page with C#

Post by Mechano »

Hey guys..
I have problem. The following is a method I call to have a users credentials checked at the start of my page. When I click the button that calls this method however, it gives me an error stating : "No value given for one or more required parameters"

public void doLogin()
{
string UserN = "";
string PassW = "";
try
{
// Create OleDbConnection for login purposes. The while loop sets the vars and the if statement checks it.
string readCommand = "SELECT * FROM Jobs WHERE Username='" + UsernameTextbox.Text + "'";
OleDbConnection loginConnection = new OleDbConnection();
loginConnection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\JobNet\Database\jobs.mdb;Persist Security Info=False";
OleDbCommand loginCommand = new OleDbCommand(readCommand,loginConnection);
loginConnection.Open();
OleDbDataReader loginR = loginCommand.ExecuteReader();
while (loginR.Read())
{
UserN = loginR["Username"].ToString();
PassW = loginR["Password"].ToString();

if ((UsernameTextbox.Text == UserN) && (PasswordTextBox.Text == PassW))
{
Label3.Text = "Success!";
}
}
loginConnection.Close();
}
catch (OleDbException exc)
{
Label3.Text = "Error : " + exc.Message;
}
}



WHAT AM I MISSING??? :? :?

I'm using VS.Net 2003 and .Net Framework version 1.1
wit_skapie
Moderator Emeritus
Posts: 6866
Joined: 12 Dec 2003, 02:00
Location: JHB
Contact:

Post by wit_skapie »

+/- 2 lines....
Mechano
Registered User
Posts: 291
Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:

Post by Mechano »

And those lines are? If I may ask?
Y0da
Moderator Emeritus
Posts: 5865
Joined: 19 Mar 2004, 02:00
Location: In a cave, In a galaxy far far away.

Post by Y0da »

Source=C:\Inetpub\wwwroot\JobNet\Database\jobs.mdb;Persist Security Info=False";
You're missing quotes after Source=

It should be
Source="C:\Inetpub\wwwroot\JobNet\Database\jobs.mdb;Persist Security Info=False";
Just when I got the hang of life they changed the rules.
Mechano
Registered User
Posts: 291
Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:

Post by Mechano »

Y0da wrote:
Source=C:\Inetpub\wwwroot\JobNet\Database\jobs.mdb;Persist Security Info=False";
You're missing quotes after Source=

It should be
Source="C:\Inetpub\wwwroot\JobNet\Database\jobs.mdb;Persist Security Info=False";
No but that entire line is in quotes. I wrote a windows app that connects to the same database and it works.
loginConnection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\JobNet\Database\jobs.mdb;Persist Security Info=False";
You can't have quotes in quotes. Then is asks for an additional ";". I'm completely confused!
Y0da
Moderator Emeritus
Posts: 5865
Joined: 19 Mar 2004, 02:00
Location: In a cave, In a galaxy far far away.

Post by Y0da »

My bad. Didn't read properly.
Just when I got the hang of life they changed the rules.
Y0da
Moderator Emeritus
Posts: 5865
Joined: 19 Mar 2004, 02:00
Location: In a cave, In a galaxy far far away.

Post by Y0da »

That error is definitly data related and I'm thinking your Select statement. I just can't put my finger on it.
Just when I got the hang of life they changed the rules.
Mechano
Registered User
Posts: 291
Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:

Post by Mechano »

Thought so as well. What confuses me is the fact that I copied it EXACTLY from a windows app in which it works.
Y0da
Moderator Emeritus
Posts: 5865
Joined: 19 Mar 2004, 02:00
Location: In a cave, In a galaxy far far away.

Post by Y0da »

Is there any text in the UsernameTextbox control when the script executes?
Just when I got the hang of life they changed the rules.
Garret
Registered User
Posts: 826
Joined: 18 Feb 2004, 02:00
Location: Johannesburg

Post by Garret »

Mechano : When you debug, does the connection open ?

Your ASPNET account also might not have appropriate permission to access the file system / directory (you have to do so explicitly)

if so, then your problem is in the CommandText of your command, with relation to the actual schema of you database.

does the jobs table have these fields your trying to read out ?

try this rather :
"SELECT UserName, Password FROM Jobs WHERE Username='" + UsernameTextbox.Text + "'"
Mechano
Registered User
Posts: 291
Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:

Post by Mechano »

Y0da wrote:Is there any text in the UsernameTextbox control when the script executes?
yep there is
Garret wrote:Mechano : When you debug, does the connection open ?
How do I check. I do have a
loginConnection.Open() and
loginConnection.Close()
statement
Garret
Registered User
Posts: 826
Joined: 18 Feb 2004, 02:00
Location: Johannesburg

Post by Garret »

can you go into debug mode ?
Mechano
Registered User
Posts: 291
Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:

Post by Mechano »

:oops: :oops: :oops: :oops: :oops:

/me = very ashamed now

I called the wrong table in my database

Thankyou for your help guys. I would'nt have noticed had you not said a few key things.

(And I want to become a MCAD?)
:stupid:
Post Reply