gib65
01-12-2011, 09:14 PM
Hello,
I'm trying to build a login page and I'm having trouble programming the connection to the database.
The page can be found at http://www.shahspace.com/autobody/index.aspx
Here's the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@Page Explicit="true" Language="VB" Debug="true" Autoeventwireup="false" EnableSessionState="False" EnableViewState="False" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
<html>
<head>
<title>Autobody</title>
</head>
<script runat="server">
Dim Connection As MySqlConnection
Dim MDA As MySqlDataAdapter
Dim DS As DataSet
Function Connect() As String
Dim ConStr As String = "server=localhost; user id=gib; password=gibpw; database=autobody;"
Connection = New MySqlConnection(ConStr)
MDA = new MySqlDataAdapter()
DS = new DataSet()
Connection.open()
Return "OK"
End Function
</script>
<body>
<form runat="server">
<table cellpadding=0 cellspacing=0 border=1>
<tr><td colspan=2>Please log in:</td></tr>
<tr>
<td>Username:</td>
<td style="width: 200px;"><asp:textbox style="width: 200px;" id="username_textbox" text="" runat="server"/></td>
</tr>
<tr>
<td>Password:</td>
<td style="width: 200px;"><asp:textbox style="width: 200px;" id="password_textbox" text="" textmode="password" runat="server"/></td>
</tr>
<tr><td colspan=2><asp:button id="login_button" text="login" runat="server" /></td></tr>
</table>
<!-- AutoPostBack=true -->
</form>
</body>
</html>
The error I get tells me that MySqlConnection is not defined and the troublesome line is:
Dim Connection As MySqlConnection
I know for fact that the importation of MySql.Data.MySqlClient caused problems earlier (it couldn't be found) but I got around it by commenting it out. Now that I need it, I'm uncommenting it, but it's still causing problems.
A lot of the code above I copied over from a site that I know works (http://www.cactusridgerr.com/contact.htm). Among other things, I copied over the page and importation statements, as well as some external files and folders:
aspnet_client/system_web/1_1_4322/SmartNav.htm
aspnet_client/system_web/1_1_4322/smartnav.js
aspnet_client/system_web/1_1_4322/webuivalidation.js
bin/MySql.Data.dll
Web.Config
Web.Config looks like this:
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
I'm thinking that as long as I have bin/MySql.Data.dll, I should be fine. I'm obviously wrong. Can someone else see the problem?
Thanks for your help.
I'm trying to build a login page and I'm having trouble programming the connection to the database.
The page can be found at http://www.shahspace.com/autobody/index.aspx
Here's the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@Page Explicit="true" Language="VB" Debug="true" Autoeventwireup="false" EnableSessionState="False" EnableViewState="False" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
<html>
<head>
<title>Autobody</title>
</head>
<script runat="server">
Dim Connection As MySqlConnection
Dim MDA As MySqlDataAdapter
Dim DS As DataSet
Function Connect() As String
Dim ConStr As String = "server=localhost; user id=gib; password=gibpw; database=autobody;"
Connection = New MySqlConnection(ConStr)
MDA = new MySqlDataAdapter()
DS = new DataSet()
Connection.open()
Return "OK"
End Function
</script>
<body>
<form runat="server">
<table cellpadding=0 cellspacing=0 border=1>
<tr><td colspan=2>Please log in:</td></tr>
<tr>
<td>Username:</td>
<td style="width: 200px;"><asp:textbox style="width: 200px;" id="username_textbox" text="" runat="server"/></td>
</tr>
<tr>
<td>Password:</td>
<td style="width: 200px;"><asp:textbox style="width: 200px;" id="password_textbox" text="" textmode="password" runat="server"/></td>
</tr>
<tr><td colspan=2><asp:button id="login_button" text="login" runat="server" /></td></tr>
</table>
<!-- AutoPostBack=true -->
</form>
</body>
</html>
The error I get tells me that MySqlConnection is not defined and the troublesome line is:
Dim Connection As MySqlConnection
I know for fact that the importation of MySql.Data.MySqlClient caused problems earlier (it couldn't be found) but I got around it by commenting it out. Now that I need it, I'm uncommenting it, but it's still causing problems.
A lot of the code above I copied over from a site that I know works (http://www.cactusridgerr.com/contact.htm). Among other things, I copied over the page and importation statements, as well as some external files and folders:
aspnet_client/system_web/1_1_4322/SmartNav.htm
aspnet_client/system_web/1_1_4322/smartnav.js
aspnet_client/system_web/1_1_4322/webuivalidation.js
bin/MySql.Data.dll
Web.Config
Web.Config looks like this:
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
I'm thinking that as long as I have bin/MySql.Data.dll, I should be fine. I'm obviously wrong. Can someone else see the problem?
Thanks for your help.