赞
踩
VB与MySQL连接及数据写入和检索
1.VB 代码
-----------------------------------------------------------------------------------------
'System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'On Error GoTo Err1
Dim pubsSQLConn As MySqlConnection 'db 连接
Dim conStr As String
pubsSQLConn = New MySqlConnection
conStr = "server=localhost;user id=root;pwd=root;database=vb;port=3306" '连接字符串
pubsSQLConn.ConnectionString = conStr
pubsSQLConn.Open()
Dim tr As MySqlTransaction = pubsSQLConn.BeginTransaction '事务
Dim sql As String
sql = "select * from user" '如果是select之
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。