sjn78 Posted November 6, 2003 Posted November 6, 2003 I have searched around on the web and this site and haven't come across what I need. Maybe i'm not looking in the right places, but anyway.. I have an access database with user name/passwords and a webform with a textbox for username and another for password. I have worked with the oledb connection and understand that in an application but I am stumped on how to do it for a webpage. If anyone could point me in the right direction or show me an example I would greatly appreciate it. Quote
*Gurus* Derek Stone Posted November 6, 2003 *Gurus* Posted November 6, 2003 The database connection code is exactly the same in a Web Form as it is in a Windows Form. Quote Posting Guidelines
sjn78 Posted November 7, 2003 Author Posted November 7, 2003 I tried doing that but when I got to filling the dataset it came up with an error. I can't give you the error message now as I'm at work. When I get home i will post what code I use and the error. Quote
sjn78 Posted November 7, 2003 Author Posted November 7, 2003 Ok, this is what I have Code: Function CheckLogin(ByVal username As String, ByVal password As String) Dim sql As String = "SELECT * FROM User WHERE name = '" & username & "' AND password = '" & password & "'" Dim objDsName = New DataSet() Dim objDaName = New OleDbDataAdapter(sql, cnstring) objDaName.Fill(objDsName, "Temp") If objDsName.tables(0).rows.count = 1 Then Panel3.Visible = True Panel4.Visible = False Else Panel3.Visible = False Panel4.Visible = True End If objDsName.dispose() objDaName.dispose() End Function Error: Server Error in '/WebApplication1' Application. -------------------------------------------------------------------------------- URI formats are not supported. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: URI formats are not supported. Source Error: Line 62: Dim objDsName = New DataSet() Line 63: Dim objDaName = New OleDbDataAdapter(sql, cnstring) Line 64: objDaName.Fill(objDsName, "Temp") Line 65: Line 66: If objDsName.tables(0).rows.count = 1 Then Source File: c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb Line: 64 Stack Trace: [ArgumentException: URI formats are not supported.] Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) WebApplication1.WebForm1.CheckLogin(String username, String password) in c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb:64 WebApplication1.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb:52 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain() Quote
*Gurus* Derek Stone Posted November 7, 2003 *Gurus* Posted November 7, 2003 You should have turned Option Explicit and Option Strict on. They would have caught your error. Dim objDsName [b]As DataSet[/b] = New DataSet() Dim objDaName [b]As OleDbDataAdapter[/b] = New OleDbDataAdapter(sql, cnstring) Quote Posting Guidelines
sjn78 Posted November 8, 2003 Author Posted November 8, 2003 Ok, I did that but still get URI formats are not supported error. It throws the error on the line where i try to fill the dataset. Quote
*Gurus* Derek Stone Posted November 8, 2003 *Gurus* Posted November 8, 2003 What is the exact value (copy and paste) of "cnstring"? Quote Posting Guidelines
sjn78 Posted November 10, 2003 Author Posted November 10, 2003 cnstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://localhost/WebApplication1/data.mdb;" Quote
*Gurus* Derek Stone Posted November 10, 2003 *Gurus* Posted November 10, 2003 You shouldn't be specifying a URI in the connection string. Instead map the file to an absolute path. Quote Posting Guidelines
sjn78 Posted November 11, 2003 Author Posted November 11, 2003 Ok, now I can get a little further!!... I now have an error that says Syntax Error in From clause. The error occurs when I fill the dataset. sql = "SELECT name, password FROM User WHERE name = '" & TextBox1.Text & "' AND password = '" & TextBox2.Text & "'" I break the program to see if the variables are correct and they are what the textbox's have in them. And yes, I have made sure the database table name and fields are correct. This is getting to me now!!! You said to point to the database where it resides on the computer, but how do I set it up when it is on a webserver somewhere? Quote
fadi Posted November 11, 2003 Posted November 11, 2003 look access is somehow an idiot in this issue(all issues i think), i have two propasals; first try to put the complete name in the select such as [tablename].[fieldname];if this didnt work, try changing the names of your fields, believe me this sometimes work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.