Dim SQLServer As String
Dim Database As String
Dim Username As String
Dim Password As String
SQLServer = e.Form.Controls("TextBox5").Value ' 服务器地址
Database = e.Form.Controls("TextBox6").Value ' 数据库文件
Username = e.Form.Controls("TextBox7").Value ' SQL用户名
Password = e.Form.Controls("TextBox8").Value ' SQL密码
Dim ErrMsg As String
Dim Conn As String ="Provider=SQLOLEDB;Data Source=" & SQLServer & ";Initial Catalog=" & Database & ";User ID=" & Username & ";Password=" & Password & ";Persist Security Info=False;"
If Connections.TryConnect(Conn,ErrMsg) = False Then
MessageBox.Show("数据源无法连通!原因:" & ErrMsg)
Else
MessageBox.Show("数据源已连通!")
End If
提示数据库源已连通,但是执行下面的代码又提示出错了
Dim Builder As New ADOXBuilder("'" & Database & "' ")
Dim tbl As ADOXTable
Builder.Open()
tbl = Builder.NewTable(“社员信息管理") '创建表
With tbl
.AddColumn("单位号" ,ADOXType.String, 4)
.AddColumn("账号" ,ADOXType.String, 20)
.AddColumn("户名" ,ADOXType.String, 20)
.AddColumn("联系电话" ,ADOXType.String, 20)
.AddColumn("地址" ,ADOXType.String, 50)
.AddColumn("业务类型" ,ADOXType.String, 8)
.AddColumn("占用费率" ,ADOXType.Double)
.AddColumn("业务日期" ,ADOXType.DateTime)
.AddColumn("密码" ,ADOXType.String, 20)
.AddColumn("身份证号" ,ADOXType.String, 20)
End With
Builder.AddTable(tbl,True, True) '增加表
提示不存在数据源