excel连接mysql失败怎么办

1518
2021/1/5 8:27:45
栏目: 云计算
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

excel连接mysql失败怎么办

excel连接mysql失败的解决方法

当excel连接mysql失败时可以在excel中添加以下代码即可连接到MySQL。

Public Sub nckxr()

Dim cnn As ADODB.ConnectionDim cnnstr As String, mydata As String

mydata = "nckxr" '指定数据库名称

cnnstr = "providet=SQLoledb;" _

& "user id=sa;" _

& "password=111;" _

& "date source=ZBS3;" _

& "initial catalog=" & mydata

set cnn = new ADODB.Connectioncnn.connectionstring = cnnstr

On Error Resume Next

cnn.Open

On Error GoTo 0

If cnn.State = adstateopen Then

MsgBox "数据库连接成功!", vbInformation, "连接数据库"

Else

MsgBox "数据库连接失败!", vbInformation, "连接数据库"

End If

Set cnn = Nothing

End Sub

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: mysql创建外键约束总不成功怎么办