I am not really sure what I should be asking here. I will explain the best I can.
I have this login webform, the user will enter their username and password, which is then supposed to be checked by the ms access database to verify it exists or is correct.
I am getting this error: "The Microsoft Jet database engine cannot find the input table or query 'tblCustRecords'. Make sure it exists and that its name is spelled correctly."
I am not really sure how to fix this, I know I have mapped this to the correct path.
thanks for the heads up I will look into the link you gave me
Hi tricket7,
Any Progess? Does the link provided by MellowshipSlinky is useful to you?
The error: "The Microsoft Jet database engine cannot find the input table or query 'tblCustRecords'. Make sure it exists and that its name is spelled correctly."
just means can not find tblCustRecords. I want to know if it the connection string is correct. Try to check it!
Thanks,
Amy Peng
Please mark the replies as answers if they help or unmark if not.
Feedback to us
tricket7
Member
5 Points
47 Posts
visual studio webform exception handling error
Nov 14, 2012 04:34 PM|LINK
I am not really sure what I should be asking here. I will explain the best I can.
I have this login webform, the user will enter their username and password, which is then supposed to be checked by the ms access database to verify it exists or is correct.
I am getting this error: "The Microsoft Jet database engine cannot find the input table or query 'tblCustRecords'. Make sure it exists and that its name is spelled correctly."
I am not really sure how to fix this, I know I have mapped this to the correct path.
here is my webform and codebehind
webform:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index1.aspx.cs" Inherits="index1.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Delta Audit Services Login</title> <style type="text/css"> .style1 { color: #000080; } .style2 { width: 176px; } .style8 { color:#FF0000; width: 176px; } </style> </head> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <!-- ********* Top Logo *********** --> <tr> <td><img src="http://www.logisource.com/images/spacer.gif" height="1" width="20" alt="line"/>A Logisource Division</td> <td align="right"> <!-- Display Date --> <script type="text/javascript" language="javascript"> <!-- Begin d = new Array( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ); m = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); today = new Date(); day = today.getDate(); year = today.getYear(); if (year < 2000) year = year + 1900; end = "th"; if (day == 1 || day == 21 || day == 31) end = "st"; if (day == 2 || day == 22) end = "nd"; if (day == 3 || day == 23) end = "rd"; day += end; document.write("<font face='Verdana, Arial, Helvetica' size='1'>"); document.write(d[today.getDay()] + ", " + m[today.getMonth()] + " "); document.write(day + ", " + year); document.write("</font><img src='http://www.logisource.com/images/spacer.gif' height='1' width='20'>"); // End --> </script> </td></tr> <tr><td valign="top" colspan="2"><img src="http://www.logisource.com/images/line.gif" height="1" width="100%" alt="line"/></td></tr> </table> <table width="100%"> <tr> <td align="center" valign="top"> <span class="style1"> New users can </span> <a href="signup.aspx"> <span class="style1">register here.</span></a><br /> <form id="form1" runat="server"> <div> <table border="3" cellpadding="0" cellspacing="1" style="background-color: #EBEDEC; border-color: #C0C0C0; border-style: solid; border-width: 2px 20px 2px 20px"> <tr> <td> <table border="0" width="230" cellpadding="4"> <tr> <td colspan="2" align="left"> <strong style="color: #000080">Please Login.</strong></td> </tr> <tr> <td class="style2"> <asp:Label ID="lbl_username" runat="server" Text="Username" style="color: #000080"></asp:Label></td> <td> <asp:TextBox ID="txt_username" runat="server"></asp:TextBox></td> </tr> <tr> <td class="style2"> <asp:Label ID="lbl_password" runat="server" Text="Password" style="color: #000080"></asp:Label></td> <td> <asp:TextBox ID="txt_password" TextMode="Password" runat="server"></asp:TextBox></td> </tr> <tr> <td colspan="2"> <asp:Button ID="btn_submit" runat="server" Text="Login" onclick="btnSubmit_Click" ></asp:Button></td></tr> </tr> </table> <tr> <td class="style8" align="center"><asp:Label ID="labelMessage" runat="server" Text=""></asp:Label></td></tr> </td> </tr> </table> </form> </div> <br /> If you have difficulty accessing the system or cannot remember your username and password, please contact Logisource Support via email at <a href="mailto:support@logisource.com">support@logisource.com</a>. <br /><br /> <em>Unauthorized access to this system is strictly prohibited.</em> <br /><br /><br /> Contents Copyright © 2003 <a href="http://www.logisource.com">Logisource</a>. All rights reserved. </td> </tr> </table> </body> </html>and my codebehind
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.OleDb; namespace index1 { public partial class WebForm1 : System.Web.UI.Page { System.Data.OleDb.OleDbConnection con; DataSet ds1; protected void Page_Load(object sender, EventArgs e) { con = new System.Data.OleDb.OleDbConnection(); ds1 = new DataSet(); } protected void btnSubmit_Click(object sender, EventArgs e) { con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=/LOGI2SERVER/apps/Logi_Website/prosearchusers.mdb"; string cmdstr = "Select count(*) from tblCustRecords where Username='" + txt_username.Text + "'"; OleDbCommand checkUser = new OleDbCommand(cmdstr, con); con.Open(); int temp = Convert.ToInt32(checkUser.ExecuteScalar().ToString()); if (temp == 1) { string cmdstr2 = "Select Password from tblCustRecords where Password='" + txt_password.Text + "'"; OleDbCommand pass = new OleDbCommand(cmdstr2, con); string password = pass.ExecuteScalar().ToString(); if (password == txt_password.Text) { labelMessage.Visible = true; labelMessage.Text = "you are logged in"; } else { labelMessage.Visible = true; labelMessage.Text = "Invalid password..!!"; } } else { labelMessage.Visible = true; labelMessage.Text = "Invalid username..!!"; } labelMessage.Text = "*Incorrect Password or Username"; } } }Is this correct?
MellowshipSl...
Member
28 Points
9 Posts
Re: visual studio webform exception handling error
Nov 14, 2012 06:06 PM|LINK
Sorry, I don't have an answer as to why you're getting that error.
BUT ! your SQL statements are prime candidates for SQL Injection attacks. You should try for parameterized queries.
see https://www.owasp.org/index.php/SQL_Injection for a better explanation, look at example #2 in particular
tricket7
Member
5 Points
47 Posts
Re: visual studio webform exception handling error
Nov 14, 2012 07:13 PM|LINK
thanks for the heads up I will look into the link you gave me
Amy Peng - M...
Star
10199 Points
964 Posts
Microsoft
Re: visual studio webform exception handling error
Nov 16, 2012 04:09 AM|LINK
Hi tricket7,
Any Progess? Does the link provided by MellowshipSlinky is useful to you?
The error: "The Microsoft Jet database engine cannot find the input table or query 'tblCustRecords'. Make sure it exists and that its name is spelled correctly." just means can not find tblCustRecords. I want to know if it the connection string is correct. Try to check it!
Thanks,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store
geniusvishal
Star
14306 Points
2820 Posts
Re: visual studio webform exception handling error
Nov 16, 2012 04:21 AM|LINK
Refer:
http://support.microsoft.com/kb/287696
My Website
www.dotnetvishal.com
tricket7
Member
5 Points
47 Posts
Re: visual studio webform exception handling error
Nov 16, 2012 11:47 AM|LINK
I have not had the chance to go back and look at the program yet, hoping to have some time this weekend.
tricket7
Member
5 Points
47 Posts
Re: visual studio webform exception handling error
Nov 20, 2012 01:55 PM|LINK
I didn't know! I am fairly new to this, how do I try for parameterized queries?
tricket7
Member
5 Points
47 Posts
Re: visual studio webform exception handling error
Nov 20, 2012 01:58 PM|LINK
I checked and the connection string is correct, I did change it to the copy I have on my desktop, but now I get this error message
"OleDbException was unhandled by user code
No value given for one or more required parameters and it
references this line of code
tricket7
Member
5 Points
47 Posts
Re: visual studio webform exception handling error
Nov 20, 2012 02:04 PM|LINK
I am posting the changes I have made below:
mostly changed the code behind, but I am getting a new error
"System.NullReferenceException: Object reference not set to an instance of an object."
log in form:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index1.aspx.cs" Inherits="index1.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Delta Audit Services Login</title> <style type="text/css"> .style1 { color: #000080; } .style2 { width: 176px; } .style8 { color:#FF0000; width: 176px; } </style> </head> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <!-- ********* Top Logo *********** --> <tr> <td><img src="http://www.logisource.com/images/spacer.gif" height="1" width="20" alt="line"/>A Logisource Division</td> <td align="right"> <!-- Display Date --> <script type="text/javascript" language="javascript"> <!-- Begin d = new Array( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ); m = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); today = new Date(); day = today.getDate(); year = today.getYear(); if (year < 2000) year = year + 1900; end = "th"; if (day == 1 || day == 21 || day == 31) end = "st"; if (day == 2 || day == 22) end = "nd"; if (day == 3 || day == 23) end = "rd"; day += end; document.write("<font face='Verdana, Arial, Helvetica' size='1'>"); document.write(d[today.getDay()] + ", " + m[today.getMonth()] + " "); document.write(day + ", " + year); document.write("</font><img src='http://www.logisource.com/images/spacer.gif' height='1' width='20'>"); // End --> </script> </td></tr> <tr><td valign="top" colspan="2"><img src="http://www.logisource.com/images/line.gif" height="1" width="100%" alt="line"/></td></tr> </table> <table width="100%"> <tr> <td align="center" valign="top"> <span class="style1"> New users can </span> <a href="signup.aspx"> <span class="style1">register here.</span></a><br /> <form id="form1" runat="server"> <div> <table border="3" cellpadding="0" cellspacing="1" style="background-color: #EBEDEC; border-color: #C0C0C0; border-style: solid; border-width: 2px 20px 2px 20px"> <tr> <td> <table border="0" width="230" cellpadding="4"> <tr> <td colspan="2" align="left"> <strong style="color: #000080">Please Login.</strong></td> </tr> <tr> <td class="style2"> <asp:Label ID="lbl_username" runat="server" Text="Username" style="color: #000080"></asp:Label></td> <td> <asp:TextBox ID="txt_username" runat="server"></asp:TextBox></td> </tr> <tr> <td class="style2"> <asp:Label ID="lbl_pass" runat="server" Text="Password" style="color: #000080"></asp:Label></td> <td> <asp:TextBox ID="txt_pass" TextMode="Password" runat="server"></asp:TextBox></td> </tr> <tr> <td colspan="2"> <asp:Button ID="btn_submit" runat="server" Text="Login" onclick="btnSubmit_Click" ></asp:Button></td></tr> </tr> </table> <tr> <td class="style8" align="center"><asp:Label ID="labelMessage" runat="server" Text=""></asp:Label></td></tr> </td> </tr> </table> </form> </div> <br /> If you have difficulty accessing the system or cannot remember your username and password, please contact Logisource Support via email at <a href="mailto:support@logisource.com">support@logisource.com</a>. <br /><br /> <em>Unauthorized access to this system is strictly prohibited.</em> <br /><br /><br /> Contents Copyright © 2003 <a href="http://www.logisource.com">Logisource</a>. All rights reserved. </td> </tr> </table> </body> </html>code behind:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.OleDb; using System.Configuration; namespace index1 { public partial class WebForm1 : System.Web.UI.Page { //System.Data.OleDb.OleDbConnection con; DataSet ds1; protected void Page_Load(object sender, EventArgs e) { // con = new System.Data.OleDb.OleDbConnection(); //ds1 = new DataSet(); } protected void btnSubmit_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Users\\Christie\\Desktop\\Christie\\Logisource\\FB Inquiry\\access files\\prosearchusers.mdb"].ConnectionString); con.Open(); string cmdStr = "select count(*)from tblCustRecords where username= txt_username.Text AND password = txt_pass.Text"; OleDbCommand Checkuser = new OleDbCommand(cmdStr, con); Checkuser.Parameters.AddWithValue("@username", txt_username.Text); Checkuser.Parameters.AddWithValue("@password", txt_pass.Text); if ((int)Checkuser.ExecuteScalar() > 0) { //Session["New"] = txt_username.Text; //Response.Redirect("Secure.aspx"); labelMessage.Visible = true; labelMessage.Text = "It works.."; } else { labelMessage.Visible = true; labelMessage.Text = "invalid credentials.."; } } } }Amy Peng - M...
Star
10199 Points
964 Posts
Microsoft
Re: visual studio webform exception handling error
Nov 21, 2012 12:10 AM|LINK
Hi tricket7,
This error occurs when you attempt to access a property or method of an object that is null.
My suggestion is always to put the debugger in debug mode, and look for nulls, after them, when you find one, there your problem is. Just have a try.
Thanks,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store