vb访问mysql怎么写 vb和mysql如何连接

vb访问mysql

需要安装MYSQL ODBC驱动程序.下载地址: Application Programming Interfaces (APIs) Official APIs: The C API is included with the server, above. Connector/ODBC - MySQL ODBC driver Connector/ODBC 3.52 -- development release Connector/ODBC 3.51 -- production release Connector/ODBC 2.50 -- old release //呵,我用的是这个,内有9X/NT版本的驱动 装成功以后,在ODBC数据源建一个MYSQL的ODBC(一般在最下面):输入ODBC名,用户,密码,数据库名等. 接下来就用这个ODBC进行联接就可以了.(当然你要先启动MYSQL)

创新互联公司是一家专注于网站设计制作、成都网站制作与策划设计,旅顺口网站建设哪家好?创新互联公司做网站,专注于网站建设十载,网设计领域的专业建站公司;建站业务涵盖:旅顺口等地区。旅顺口做网站价格咨询:13518219792

如何用VB连接远程的mysql数据库

1、显示密码

如:MySQL

连接远程数据库(192.168.5.116),端口“3306”,用户名为“root”,密码“123456”

C:/mysql -h

192.168.5.116 -P 3306 -u root -p123456

2、隐藏密码

如:MySQL 连接本地数据库,用户名为“root”

C:/mysql -h

localhost -u root -p

Enter password:

vb高手进,vb连接mysql数据库,怎么把数据写入数据库!

必须安装mysql的驱动才行,不管是vb还是c++都需要这个驱动。

代码如下:

public

function

exemysql(byval

sql

as

string)

as

adodb.recordset

sql

=

trim$(sql)

set

conn

=

new

adodb.connection

set

rs

=

new

adodb.recordset

conn.open

"driver=mysql

odbc

3.51

driver;"

_

"server=服务器地址;"

_

"port=3306;"

_

"database=数据库名;"

_

"uid=用户名;"

_

"pwd=密码"

conn.defaultdatabase

=

"数据库名"

conn.cursorlocation

=

aduseclient

set

rs.activeconnection

=

conn

rs.locktype

=

adlockbatchoptimistic

rs.cursortype

=

adopenkeyset

rs.open

sql

set

exesql

=

rs

set

rs

=

nothing

set

conn

=

nothing

end

function

在VB中,如何连接MYSQL

楼上讲的是VB2005的连接方法,不知道你用的是什么版本的VB,我给你一个VB6.0的连接方法吧

先在本机上安装最新的ODBC CONNECTER/mysql

无需设置ODBC,就可以使用.

注意MYSQL的帐户登录是根据主机的,设置好MYSQL的帐户后再做测试.

测试代码:

Dim conn As ADODB.Connection

Dim rs As ADODB.Recordset

Dim fld As ADODB.Field

Dim sql As String

'connect to MySQL server using MySQL ODBC 3.51 Driver

Set conn = New ADODB.Connection

conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _

"SERVER=192.168.0.1;" _

" DATABASE=db_name;" _

"UID=username;PWD=password; OPTION=3"

conn.Open

'create table

conn.Execute "DROP TABLE IF EXISTS my_ado"

conn.Execute "CREATE TABLE my_ado(id int not null primary key, name varchar(20)," _

"txt text, dt date, tm time, ts timestamp)"

'direct insert

conn.Execute "INSERT INTO my_ado(id,name,txt) values(1,100,'venu')"

conn.Execute "INSERT INTO my_ado(id,name,txt) values(2,200,'MySQL')"

conn.Execute "INSERT INTO my_ado(id,name,txt) values(3,300,'Delete')"

Set rs = New ADODB.Recordset

rs.CursorLocation = adUseServer

'fetch the initial table ..

rs.Open "SELECT * FROM my_ado", conn

Debug.Print rs.RecordCount

rs.MoveFirst

Debug.Print String(50, "-") "Initial my_ado Result Set " String(50, "-")

For Each fld In rs.Fields

Debug.Print fld.name,

Next

Debug.Print

Do Until rs.EOF

For Each fld In rs.Fields

Debug.Print fld.value,

Next

rs.MoveNext

Debug.Print

Loop

rs.Close

conn.Close

vb6.0如何连接MYSQL数据库?

最简单的办法是:在VB里添加一个ADO部件,将其放到窗体中,然后右键选择属性,在其属性页的下面有个生成连接字符串的项,点击其后的按钮,然后一步步的来做(很简单的),然后连接字符串就会在那里生成,只要拷贝这个字符串,就可以用ADODB来连接了。。。

我想把VB.NET连接MYSQL数据库,代码怎么写啊?

和SQL数据库差不多的,下面是我用vb6.0连接本地mysql数据库的连接字符串

"driver={MySQL ODBC 3.51 Driver};server=127.0.0.1;database=mysql;uid=root;pwd=sasa"


新闻名称:vb访问mysql怎么写 vb和mysql如何连接
文章出自:http://abwzjs.com/article/hpesdo.html