您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



vb 获得计算机名后,cn连接串怎么写?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vb 获得计算机名后,cn连接串怎么写?[已结贴,结贴人:miclee521]
发表于:2007-08-08 09:24:48 楼主
以前是
cn.open   "provider=sqloledb;data   source=lg;user   id=sa;password=cycwxl;initial   catalog=tjzxsk;persist   security   info=true "


现在获得机器名为n
dim   n   as   string   *   20
dim   pcname   as   string
getcomputername   n,   20
'msgbox   n

cn的连接串datasource   部分该怎么写?
谢谢
发表于:2007-08-08 09:34:181楼 得分:10
cn.open   "provider=sqloledb;data   source= "   &   n   &   "   ;user   id=sa;password=cycwxl;initial   catalog=tjzxsk;persist   security   info=true "
发表于:2007-08-08 14:10:342楼 得分:0
楼上代码调试没有通过
提示:无效的授权说明
发表于:2007-08-09 16:14:553楼 得分:10


dim   strconn   as   string
strconn= "provider=sqloledb;user   id=sa;password=cycwxl;initial   catalog=tjzxsk;persist   security   info=true;data   source= "   &   n

自己把这个连接符debug.print出来嘛
发表于:2007-08-16 11:39:234楼 得分:0
谢谢   莫依
问题解决了
参考:
private   sub   command1_click()
dim   ret   as   long
dim   buffer   as   string   *   256
dim   computername   as   string
ret   =   getcomputername(buffer,   len(buffer))
if   ret   <>   0   then
computername   =   left$(buffer,   instr(1,   buffer,   vbnullchar)   -   1)
msgbox   "本机的机器名: "   &   computername
end   if
end   sub


快速检索

最新资讯
热门点击