asp.net连接mysql连接字符串究竟应该怎么写?我的代码如下,但是却连接不是数据库,求高手指点下 20
PrivateSubbind()DimconnAsMySQLConnection=NewMySQLConnection(NewMySQLConnectionString(...
Private Sub bind()
Dim conn As MySQLConnection= New MySQLConnection(New MySQLConnectionString("localhost", "paintingnet", "root", "root", 3306).AsString)
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim commn As New MySQLCommand("set names gb2312", conn)
commn.ExecuteNonQuery()
Dim Data As New DataTable
Dim s As String = "SELECT * FROM auction"
Dim da As New MySQLDataAdapter(s, conn)
da.Fill(Data)
gvIndex.DataSource = Data
gvIndex.DataBind()
Catch ex As MySQLDriverCS.MySQLException
Dim str As String = ex.Message
Response.Write("<script>alert('连接数据失败,请联系管理员!')</script>")
Return
End Try
End Sub 展开
Dim conn As MySQLConnection= New MySQLConnection(New MySQLConnectionString("localhost", "paintingnet", "root", "root", 3306).AsString)
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim commn As New MySQLCommand("set names gb2312", conn)
commn.ExecuteNonQuery()
Dim Data As New DataTable
Dim s As String = "SELECT * FROM auction"
Dim da As New MySQLDataAdapter(s, conn)
da.Fill(Data)
gvIndex.DataSource = Data
gvIndex.DataBind()
Catch ex As MySQLDriverCS.MySQLException
Dim str As String = ex.Message
Response.Write("<script>alert('连接数据失败,请联系管理员!')</script>")
Return
End Try
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询