我在SQL-SERVER里建立了一个sale的数据库
然后在VB里建立一个project,但是我在用remote data控件时,在dataSourceName属性里找不到我上面的sale!
是不是我SQL-SERVER里的设置不对呢?
我是WIN2K professional,sql-server个人版.
书上是这么说的"设置ODBC数据源.其中验证方式中,用户名为sa,密码为空.
最后对此数据源进行测试,测试之前,先要利用SQL-SERVER服务管理器建立到数据库的所在服务器的连接,测试成功则数据源成功建立"我要怎么做呢?
拜谢各位!!!!

解决方案 »

  1.   

    怎么没人回答呢?
    :(
    对CSDN是越来越不满意了。
    高手越来越少,速度越来越慢!
    给我指条路啊!哪怕是一个UP,我也会感激的!
      

  2.   

    up
     
    到控制面板中的管理工具里 设置odbc数据源
      

  3.   

    MSRDC1控件不能应用SQL SERVER  你在以下所说的:是用ADO控件建立连接
      

  4.   

    odbc有问题新建sqlserver驱动的数据源
    名称sale_dsn,服务器请填入sqlserver数据库服务器名接下来,选择2,sqlserver的验证,登陆id=sa,密码为空接下来,选择数据库sale,完成后可以测试一下
      

  5.   

    datasourcename的下拉列表就出现了刚才我们输入的名称sale_dsn
    接下来,可以在sql属性中写sql语句
      

  6.   

    在控制面版打开ODBC选择文件DNS添加---选择最后一个----添入sale在数据源名称里---添写好sqlserver数据库服务器名-----选择sqlserver的验证,登陆id=sa,密码为空-----在第一个复选框里打对钩,选择sale数据库-----测试!在类模块中也要写好是登陆id=sa,密码为空啦
      

  7.   


    你先建一个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 = "&Ecirc;&yacute;&frac34;&Yacute;&iquest;&acirc;&Aacute;&not;&frac12;&Oacute;&Ograve;ì&sup3;&pound;&pound;&iexcl;"
            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
      

  8.   

    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