我在SQL-SERVER里建立了一个sale的数据库
然后在VB里建立一个project,但是我在用remote data控件时,在dataSourceName属性里找不到我上面的sale!
是不是我SQL-SERVER里的设置不对呢?
我是WIN2K professional,sql-server个人版.
书上是这么说的"设置ODBC数据源.其中验证方式中,用户名为sa,密码为空.
最后对此数据源进行测试,测试之前,先要利用SQL-SERVER服务管理器建立到数据库的所在服务器的连接,测试成功则数据源成功建立"我要怎么做呢?
拜谢各位!!!!
然后在VB里建立一个project,但是我在用remote data控件时,在dataSourceName属性里找不到我上面的sale!
是不是我SQL-SERVER里的设置不对呢?
我是WIN2K professional,sql-server个人版.
书上是这么说的"设置ODBC数据源.其中验证方式中,用户名为sa,密码为空.
最后对此数据源进行测试,测试之前,先要利用SQL-SERVER服务管理器建立到数据库的所在服务器的连接,测试成功则数据源成功建立"我要怎么做呢?
拜谢各位!!!!
解决方案 »
- VB啊VB又拿你搞了个系统
- 如何创建控件自定义双击事件~
- 有关判断数据库添加是否重复的问题? 金山毒霸2005免费下了
- ****请教解决方法****做一个WEB组件(CAB包),能实现两部分功能(1.FTP file1;2.RUN file1)
- 如何实现PictureBox的缩放功能?
- picturebox画线问题
- 请问用SNDPLAYSOUND怎么同时播放两个声音
- VB6做的程序,在2000下安装,出现:路径/文件访问错误。怎么回事?
- 如何令Adodc控件在数据库路径路径更新的时候不报错??请高手帮忙
- 我还是解决不了,请大家过来看看!!!!!!!!!!!!!!
- vb运行时弹出对话框或者提示上的标题:“工程1“怎么改掉???
- bmp2jpg 和DPI值的问题
:(
对CSDN是越来越不满意了。
高手越来越少,速度越来越慢!
给我指条路啊!哪怕是一个UP,我也会感激的!
到控制面板中的管理工具里 设置odbc数据源
名称sale_dsn,服务器请填入sqlserver数据库服务器名接下来,选择2,sqlserver的验证,登陆id=sa,密码为空接下来,选择数据库sale,完成后可以测试一下
接下来,可以在sql属性中写sql语句
你先建一个odbc吧!我给你一个使用ado的!Option ExplicitPrivate mvarConnType As Integer 'Á¬½Ó·½Ê½£¨1=sql server 2=access)Private mvarDBPassword As String 'Êý¾Ý¿âÃÜÂëPrivate mvarSQLServer As String 'sql server Êý¾Ý¿âµÄ·þÎñÆ÷£¨¿ÉÒÔÊÇipµØÖ·£¬Ò²¿ÉÒÔÊÇ·þÎñÆ÷Ãû³Æ£©Private mvarSQLUserID As String 'sql serverµÄÓû§IDPrivate mvarDBName As String 'Êý¾Ý¿âµÄÃû³Æ£¨¶ÔÓÚaccessÀ´Ëµ£¬¸Ã²ÎÊýΪÍêÕûµÄÎļþ·¾¶Private conn As ADODB.Connection 'Á¬½Ó¶ÔÏóPrivate rst As ADODB.Recordset '¼Ç¼¶ÔÏóPrivate mvarLastError As String '×îºóµÄ´íÎóÄÚÈÝPublic Property Let LastError(ByVal vData As String)
mvarLastError = vData
End PropertyPublic Property Get LastError() As String
LastError = mvarLastError
End Property'Á¬½ÓÊý¾Ý¿â
Public Function ConnDB() As Boolean
On Error GoTo ConnDB_Error
Dim ConnStr As String
Select Case mvarConnType
Case 1 'Á¬½Ó sql server
ConnStr = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=" _
& mvarSQLServer & ";Initial Catalog=" & DBName & ";User ID=" & _
SQLUserID & ";Password=" & DBPassword & ";"
Case 2 'Á¬½Ó access
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& DBName & ";Jet OLEDB:Database Password=" & DBPassword & ";"
Case Else
mvarLastError = "ûÓÐÉèÖÃÊý¾Ý¿âÁ¬½Ó¶ÔÏóµÄÀàÐÍ!" & _
Chr(13) & Chr(10) & "ConnType=1---Á¬½ÓSQL SERVER" & _
Chr(13) & Chr(10) & "ConnType=2---Á¬½ÓACCESS "
ConnDB = False
Exit Function
End Select
Set conn = New ADODB.Connection
conn.Open ConnStr '½¨Á¢Á¬½Ó
If conn.State <> adStateOpen Then
mvarLastError = "Êý¾Ý¿âÁ¬½ÓÒì³££¡"
ConnDB = False
Exit Function
End If
ConnDB = True
Exit FunctionConnDB_Error:
mvarLastError = Err.Description
ConnDB = False
End FunctionPublic Property Let DBName(ByVal vData As String)
mvarDBName = vData
End PropertyPublic Property Get DBName() As String
DBName = mvarDBName
End PropertyPublic Property Let SQLUserID(ByVal vData As String)
mvarSQLUserID = vData
End PropertyPublic Property Get SQLUserID() As String
SQLUserID = mvarSQLUserID
End PropertyPublic Property Let SQLServer(ByVal vData As String)
mvarSQLServer = vData
End PropertyPublic Property Get SQLServer() As String
SQLServer = mvarSQLServer
End PropertyPublic Property Let DBPassword(ByVal vData As String)
mvarDBPassword = vData
End PropertyPublic Property Get DBPassword() As String
DBPassword = mvarDBPassword
End PropertyPublic Property Let ConnType(ByVal vData As Integer)
mvarConnType = vData
End PropertyPublic Property Get ConnType() As Integer
ConnType = mvarConnType
End Property
mvarLastError = vData
End PropertyPublic Property Get LastError() As String
LastError = mvarLastError
End Property'连接数据库
Public Function ConnDB() As Boolean
On Error GoTo ConnDB_Error
Dim ConnStr As String
Select Case mvarConnType
Case 1 '连接 sql server
ConnStr = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=" _
& mvarSQLServer & ";Initial Catalog=" & DBName & ";User ID=" & _
SQLUserID & ";Password=" & DBPassword & ";"
Case 2 '连接 access
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& DBName & ";Jet OLEDB:Database Password=" & DBPassword & ";"
Case Else
mvarLastError = "没有设置数据库连接对象的类型!" & _
Chr(13) & Chr(10) & "ConnType=1---连接SQL SERVER" & _
Chr(13) & Chr(10) & "ConnType=2---连接ACCESS "
ConnDB = False
Exit Function
End Select
Set conn = New ADODB.Connection
conn.Open ConnStr '建立连接
If conn.State <> adStateOpen Then
mvarLastError = "数据库连接异常!"
ConnDB = False
Exit Function
End If
ConnDB = True
Exit FunctionConnDB_Error:
mvarLastError = Err.Description
ConnDB = False
End FunctionPublic Property Let DBName(ByVal vData As String)
mvarDBName = vData
End PropertyPublic Property Get DBName() As String
DBName = mvarDBName
End PropertyPublic Property Let SQLUserID(ByVal vData As String)
mvarSQLUserID = vData
End PropertyPublic Property Get SQLUserID() As String
SQLUserID = mvarSQLUserID
End PropertyPublic Property Let SQLServer(ByVal vData As String)
mvarSQLServer = vData
End PropertyPublic Property Get SQLServer() As String
SQLServer = mvarSQLServer
End PropertyPublic Property Let DBPassword(ByVal vData As String)
mvarDBPassword = vData
End PropertyPublic Property Get DBPassword() As String
DBPassword = mvarDBPassword
End PropertyPublic Property Let ConnType(ByVal vData As Integer)
mvarConnType = vData
End PropertyPublic Property Get ConnType() As Integer
ConnType = mvarConnType
End Property