还没收到,SINA速度也太慢了吧,还是我设置有错,现在只是比邮票发信快些。晚饭后在和你联系。我想保留此帖好和你联系,9:00准时给分。
解决方案 »
- 如何用VB调用PPT
- LLWindowsXP1.InitSubClassing是什么?
- 电脑有问题了,帮看看,!!!!
- 用vb做串行通讯(在线等,特急)
- 如何在VB中将窗体上的BarCodeCtrl1条形码图传到datareport报表中打印出来???
- 为何我的信誉分变成了97,我是祥和朴实的公民,也没有不结的贴子!
- vb执行出错。
- <font size=10>try</font>
- 请问大家,Access2000格式的数据库中最多可以容纳多少个表?有上限吗?
- 刚做完一个带有人工智能的俄罗斯方块,有音效,有谁想试用。
- 关于winsock的发送Double类型的问题
- asp中表格与表格传递数据问题
将来在单位的其他机器上安装时,肯定要安装SQL SERVER或MSDE。
如果你的程序链接数据库使用的是连接字串,那么你就要确保这个字串所指的服务器名一定要可变。因为服务器名就是机器名。如果你用(Local),那么总是访问本地机器。用名字和IP地址都可以指向(数据库)服务器,但如果用名字,就要配置"命名管道"协议。
如果你用DSN方式连接服务器,你就要把这个DSN在安装的机器上也制作好。
对于VB来说,因为你用了ADO,连接ACCESS和链接SQL SERVER基本是一样的(除了连接字串不同)。SQL语句有些不一样。这个就要看书了。
随后给你解决你刚刚说的问题
With Adodc1
.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zwkgdata;Data Source=wjpserver" '"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\总务科库管系统\mdb\xhpk\zwkgmdb.mdb;Persist Security Info=False"
.ConnectionTimeout = 30
.CommandType = adCmdText
.RecordSource = rstsql
.Refresh
End With
假设你的recordset是rs,你的编码需要三位数字:
select case Len(CStr(rs.Fields("总编号")))
case 1
strGNum = "00" & CStr(rs.Fields("总编号"))
case 2
strGnum = "0" & CStr(rs.Fields("总编号"))
end select
对你的所有编号如此处理
CASE a.总分类编号
WHEN a.总分类编号 < 10 THEN '00' + CONVERT(CHAR(3),a.总分类编号)
WHEN a.总分类编号 >= 10 AND a.总分类编号 < 99 THEN '0' + CONVERT(CHAR(3),a.总分类编号)
END) &
(DNum =
CASE a.细分类编号
WHEN a.细分类编号 < 10 THEN '00' + CONVERT(CHAR(3),a.细分类编号)
WHEN a.细分类编号 >= 10 AND a.细分类编号 < 99 THEN '0' + CONVERT(CHAR(3),a.细分类编号)
END) &
(PNum =
CASE a.物品编号
WHEN a.物品编号 < 10 THEN '00' + CONVERT(CHAR(3),a.物品编号)
WHEN a.物品编号 >= 10 AND a.物品编号 < 99 THEN '0' + CONVERT(CHAR(3),a.物品编号)
END) as 产品编号, b.总分类名称, c.细分类名称, a.物品名称
FROM 物品目录表 as a
INNER JOIN 细分类表 as c ON a.细分类编号 = c.细分类编号
INNER JOIN 总分类表 as b ON a.总分类编号 = b.总分类编号 我这只是按照语法写的,没测试,你测试一下。
你要保证数据库文件放在这个目录下才可以。
你这是access的连接字串,不是sql2000的。
用连接字串不需要DSN
用VB启动sql服务器,要用到API。这个论坛有人问过这个问题。我现在一时找不到如何用API启动sql服务器的代码。但一定可以的。等找到了告诉你
Private Const RESOURCE_CONNECTED = &H1
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As Long
lpRemoteName As Long
lpComment As Long
lpProvider As Long
End Type
Private Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, lpNetResource As Any, lphEnum As Long) As Long
Private Declare Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" (ByVal hEnum As Long, lpcCount As Long, lpBuffer As Any, lpBufferSize As Long) As Long
Private Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Any) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
Function LetterToUNC(DriveLetter As String) As String
Dim hEnum As Long
Dim NetInfo(1023) As NETRESOURCE
Dim entries As Long
Dim nStatus As Long
Dim LocalName As String
Dim UNCName As String
Dim i As Long
Dim r As Long ' Begin the enumeration
nStatus = WNetOpenEnum(RESOURCE_CONNECTED, RESOURCETYPE_ANY, 0&, ByVal 0&, hEnum) LetterToUNC = DriveLetter 'Check for success from open enum
If ((nStatus = 0) And (hEnum <> 0)) Then
' Set number of entries
entries = 1024 ' Enumerate the resource
nStatus = WNetEnumResource(hEnum, entries, NetInfo(0), CLng(Len(NetInfo(0))) * 1024) ' Check for success
If nStatus = 0 Then
For i = 0 To entries - 1
' Get the local name
LocalName = ""
If NetInfo(i).lpLocalName <> 0 Then
LocalName = Space(lstrlen(NetInfo(i).lpLocalName) + 1)
r = lstrcpy(LocalName, NetInfo(i).lpLocalName)
End If ' Strip null character from end
If Len(LocalName) <> 0 Then
LocalName = Left(LocalName, (Len(LocalName) - 1))
End If If UCase$(LocalName) = UCase$(DriveLetter) Then
' Get the remote name
UNCName = ""
If NetInfo(i).lpRemoteName <> 0 Then
UNCName = Space(lstrlen(NetInfo(i).lpRemoteName) + 1)
r = lstrcpy(UNCName, NetInfo(i).lpRemoteName)
End If ' Strip null character from end
If Len(UNCName) <> 0 Then
UNCName = Left(UNCName, (Len(UNCName) - 1))
End If ' Return the UNC path to drive
'added the [] to seperate on printout only
LetterToUNC = UNCName ' Exit the loop
Exit For
End If
Next i
End If
End If ' End enumeration
nStatus = WNetCloseEnum(hEnum)
End Function
Private Sub Form_Load()
MsgBox "C: UNC path: " + LetterToUNC("C:")
End Sub