不能的。没有所谓绿色版的。就算是用 BAT,也是将 DLL 组件注册了才能使用。
可以将驱动在你的程序安装时一起安装也可以
在程序启动时判断有没有装 MSQL 的组件驱动,如果没有,这提示或直接执行安装 *** 作。。。
/在模块里编写(新建模块)
Public comm As New ADODBCommand
Public conn As New ADODBConnection
Public uname As String
Public pwd As String
Public ulevel As Integer
Sub main()
connConnectionString = "Provider=SQLOLEDB1;Persist Security Info=False;User ID=sa;Initial Catalog=wow;Data Source="
connOpen
Form1Show
End Sub
'判断登陆是否成功(封装函数)
Public Function isLogin(uname, pwd, ulevel) As Boolean
Dim flag As Boolean
commActiveConnection = conn
commCommandType = adCmdStoredProc
commCommandText = "isLogin"
commParameters(1)Type = adVarChar
commParameters(1)Size = 50
commParameters(1)Direction = adParamInput
commParameters(1)Value = uname
commParameters(2)Type = adVarChar
commParameters(2)Size = 50
commParameters(2)Direction = adParamInput
commParameters(2)Value = pwd
commParameters(3)Type = adInteger
commParameters(3)Size = 4
commParameters(3)Direction = adParamInput
commParameters(3)Value = ulevel
commParameters(4)Type = adInteger
commParameters(4)Size = 4
commParameters(4)Direction = adParamOutput
commExecute
If commParameters(4)Value > 0 Then
flag = True
Else
flag = False
End If
isLogin = flag
End Function
/在登陆窗体中调用封装函数实现登陆判断
Private Sub Command1_Click()
Dim uname As String
Dim pwd As String
Dim ulevel As Integer
uname = Text1Text
pwd = Text2Text
If Combo1Text = "管理员" Then
ulevel = 1
Else
ulevel = 0
End If
If isLogin(uname, pwd, ulevel) Then
MsgBox "登陆成功", vbOKOnly, "提示"
Form2Show
Unload Me
Else
MsgBox "登录失败", vbOKOnly, "提示"
End If
End Sub
Private Sub Command2_Click()
Text1Text = Clear
Text2Text = Clear
Text1SetFocus
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
Form3Show
Unload Me
End Sub
Private Sub Form_Load()
Combo1AddItem "管理员"
Combo1AddItem "用户"
End Sub
/在MYSQL企业管理器中编写存储过程:(选中以下编写的内容并执行即可生成存储过程)
create proc isLogin @uname varchar(50), @pwd varchar(50),@ulevel int, @flag int output
as
declare @count int
select @count=count() from [user] where
uname=@uname and pwd=@pwd and ulevel=@ulevel
if @count>0
set @flag=1
else
set @flag=0
create proc AddUser @uname
给分把
首先你要在工程部件里引用一个ADO Data Control 20控件,拖到窗体上
Private Sub Command1_Click()
Adodc1ConnectionString = "Driver={SQL Server};Server=MYSQL;DataBase=account2"
Adodc1RecordSource = "SELECT FROM account"
Adodc1Refresh
Adodc1RecordsetAddNew
'---------------------------添加新记录
Adodc1RecordsetFields("name") = MeText1
Adodc1RecordsetFields("password") = MeText2
Adodc1RecordsetUpdate
'-------------------------恢复初始设置
MeText1 = ""
Metext2 = ""
metext1SETFOCUS
End Sub
可以了
首先连接数据库,上网上找一下,有很多的例子,但是记得sql sever要配置,这个是很重要的,然后是按钮的程序,用connection去执行那个SQL语句,就是那个insert 语句,插入语句,如果你想判断是否重复的话,可以用recordset去执行insert语句,根据返回的recordcount去判断或者判断那个EOF还是BOF我忘了,其实这个代码还行,工作量还可以
以上就是关于vb 连接mysql数据库能不能不装驱动全部的内容,包括:vb 连接mysql数据库能不能不装驱动、【80分悬赏】怎么用VB连接MYSQL数据库来编写登陆界面、vb *** 作mysql添加记录和查询记录等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)