G
Guest
Hi,
MySql AB released their .NET Native Driver 1 Sept 2004 and I'm trying to
create a connectionstring that works according to their examples, see below
my example
I've installed their connector_net drive.
This is my code:
<%@ Page Language="vb" Debug="true" %>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim ConnStr as String
ConnStr = "Database=Test;Data Source=localhost;User
Id=yourname;Password=yourpsw;"
Dim conn As MySqlConnection = New MySqlConnection(ConnStr)
Try
conn.Open()
Status.Text = "Connection string OK!"
Catch ex As SqlException
Status.Text = ex.Message
Finally
conn.Close()
End Try
End Sub
</script>
<html>
<head>
<title>Sample ASP.NET Page</title>
</head>
<body>
<h1>Connect to datasource
</h1>
<asp:label id="Status" runat="server"></asp:label>
<br />
<br />
</body>
</html>
And I'm getting this error message
Compiler Error Message: BC30002: Type 'MySqlConnection' is not defined.
Source Error:
Line 7: Dim ConnStr as String
Line 8: ConnStr = "Database=Test;Data Source=localhost;User
Id=youruser;Password=yourpsw;"
Line 9: Dim conn As MySqlConnection = New MySqlConnection(ConnStr)
Line 10: Try
Line 11: conn.Open()
Source File:
D:\Arkiv\prog\Inetpub\wwwroot\testMySqlConnStr\testMySqlConnStr.aspx Line:
9
And this is an example from their mySqlConnection class
Public Sub InsertRow(myConnectionString As String)
' If the connection string is null, use a default.
If myConnectionString = "" Then
myConnectionString = "Database=Test;Data Source=localhost;User
Id=username;Password=pass"
End If
Dim myConnection As New MySqlConnection(myConnectionString)
Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId,
amount) Values(1001, 23, 30.66)"
Dim myCommand As New MySqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
End Sub
Any ideas on what I'm doing wrong?
TIA
Kenneth P
MySql AB released their .NET Native Driver 1 Sept 2004 and I'm trying to
create a connectionstring that works according to their examples, see below
my example
I've installed their connector_net drive.
This is my code:
<%@ Page Language="vb" Debug="true" %>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim ConnStr as String
ConnStr = "Database=Test;Data Source=localhost;User
Id=yourname;Password=yourpsw;"
Dim conn As MySqlConnection = New MySqlConnection(ConnStr)
Try
conn.Open()
Status.Text = "Connection string OK!"
Catch ex As SqlException
Status.Text = ex.Message
Finally
conn.Close()
End Try
End Sub
</script>
<html>
<head>
<title>Sample ASP.NET Page</title>
</head>
<body>
<h1>Connect to datasource
</h1>
<asp:label id="Status" runat="server"></asp:label>
<br />
<br />
</body>
</html>
And I'm getting this error message
Compiler Error Message: BC30002: Type 'MySqlConnection' is not defined.
Source Error:
Line 7: Dim ConnStr as String
Line 8: ConnStr = "Database=Test;Data Source=localhost;User
Id=youruser;Password=yourpsw;"
Line 9: Dim conn As MySqlConnection = New MySqlConnection(ConnStr)
Line 10: Try
Line 11: conn.Open()
Source File:
D:\Arkiv\prog\Inetpub\wwwroot\testMySqlConnStr\testMySqlConnStr.aspx Line:
9
And this is an example from their mySqlConnection class
Public Sub InsertRow(myConnectionString As String)
' If the connection string is null, use a default.
If myConnectionString = "" Then
myConnectionString = "Database=Test;Data Source=localhost;User
Id=username;Password=pass"
End If
Dim myConnection As New MySqlConnection(myConnectionString)
Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId,
amount) Values(1001, 23, 30.66)"
Dim myCommand As New MySqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
End Sub
Any ideas on what I'm doing wrong?
TIA
Kenneth P