VB中的adodc控件连接问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 16:29:10
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=dfsh;Data Source= 192.168.1.100
有上述语句,经测试是没有问题的。但现在要将192.168.1.100用其他控件输入的字符代替,比如用text1,将上边的192.168.1.100直接用text1.text代替是不行的,该怎么写

Data Sourse="& text1.Text &"

可以这样

source =str
str= text1.text
这样应该可以了

定义一个字符串变量 dim cmdstr as string

再联接数据库之前输入完整的联接字符串就OK;

cmdstr= "SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=dfsh;Data Source="

cmdstr=cmdstr+trim(text1.text)

provider=cmdstr

这样子就可以啦!!!!希望对你有用哈