连接vb.net mysql数据网页 [英] connect vb.net mysql data web pages

查看:61
本文介绍了连接vb.net mysql数据网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在我的项目中的本地计算机上运行了一个程序.我要保存的运行MySQL dataya的程序的特定语言环境数据的IP地址.但是现在我得到一个错误.

变量,可接受范围或与其他人发生冲突时使用的错误类型的参数"




Hello

have a program running on local machine in my project. The IP address of a particular locale data to the program I''m running a MySQL dataya want to save. But now I get an error.

"Variables, the acceptable range, or out of the wrong types of arguments used in a conflict with someone else"




Imports MySql.Data.MySqlClient
Public Class Form1
    Public conan As New MySqlConnection
    Public rs As New ADODB.Recordset

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myDB = DBNAME
        Dim myserver = 66.77.144.100 ' IP ADRESS MY MYSQL DATA
        Dim myusername = USer
        Dim mypassword = 12345
        If conan.State = ConnectionState.Closed Then
            conan.ConnectionString = "DATABASE=" & myDB & ";" _ "SERVER=" & myserver & ";user id="& myusername & ";password=" &mypassword
            conan.Open()
        End If
        rs.Open("select * from deneme", conan, 1, 3) 'PROBLEM THIS LINE
End Sub
End Class





[edit]Code block working, "Ignore HTML..." option disabled - OriginalGriff[/edit]

推荐答案

您使用的原因是否存在MySql数据库连接器的ADODB记录集? MySql连接器中内置的集成数据读取器等可能会让您更加幸运.

有一个数据读取器可以遍历记录集,类似于打开您正在执行的记录集,但与更新,添加或删除行不同,这是一些经过修改的代码,可以帮助您启动和运行.

Is there a reason you are using the ADODB recordset with the MySql database connector? You might have some more luck with the integrated data readers etc built into the MySql connector.

There is a Data Reader that can loop through recordsets similar to opening the recordset that you are doing there just not the same with updating, adding or deleting rows, this is some modified code which might help you get up and running.

Imports MySql.Data.MySqlClient

Public Class Form1
   
    Public conan As New MySqlConnection
    Public dr as MySQLDataReader

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
	Dim myDB = "DBNAME"
        Dim myServer = "66.77.144.100" ' IP ADRESS MY MYSQL DATA
        Dim myUsername = "USer"
        Dim myPassword = "12345"

	Dim connectionString as string, sSQL as string
		
	connectionString = "DATABASE=" & myDB & ";SERVER=" & myServer & ";user id="& myUsername & ";password=" & myPassword

        If conan.State = ConnectionState.Closed Then
            conan.ConnectionString = connectionString
            conan.Open()
        End If

	sSQL = "SELECT * FROM deneme;"

	Cmd = New MySqlCommand(sSQL, conan)
	dr = Cmd.ExecuteReader()

	While dr.Read
	    Response.Write dr("fieldname1")
	End While

	dr.Close()

End Sub
End Class


这篇关于连接vb.net mysql数据网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆