研发埠

标题: VBA连接SQL Server数据库, IP地址如何引用单元格上的值? [打印本页]

作者: 刘晓强    时间: 2013-7-11 14:56
标题: VBA连接SQL Server数据库, IP地址如何引用单元格上的值?
Dim cnn As ADODB.Connection   Dim rs As ADODB.Recordset   Dim sql As String, mydata As String, mytable As String   mydata = "MYSQL"     Set cnn = New ADODB.Connection   cnn.ConnectionString = &quotrovider=SQLOLEDB; User ID=saassword=123;Data Source=***.***.***.***"   cnn.Open上面的星号为数据库IP地址,填上实际IP后,可以连接上,但因为这个IP是电信的动态IP地址,经常变动,所以想将IP地址放在Sheet1.Cells(1,1)里面.但不知上面的语句该怎么修改,请各位帮助.谢谢!
作者: 淡写轻描    时间: 2013-7-11 15:07
普通浏览复制代码Dim cnn As ADODB.Connection    Dim rs As ADODB.Recordset    Dim sql As String, mydata As String, mytable As String    Dim ip as String    mydata = "MYSQL"      ip=sheet1.cells(1,1).text    Set cnn = New ADODB.Connection    cnn.ConnectionString = &quotrovider=SQLOLEDB; User ID=saassword =123;Data Source=" & ip    cnn.Open




欢迎光临 研发埠 (http://bbs.yanfabu.com/) Powered by Discuz! X3.2