delphi7写的连接sql server2000的学生管理系统程序,登录时提示Unknown database.  Alias:dbuser.
到底是何缘故?周一就要交作业了,自己弄了好久都没找到原因,唯有请各位帮助了!!

解决方案 »

  1.   

    那是因为odbc设置错误还是源码写错了?
    能详细点吗?谢谢!
      

  2.   

    好像是bde没有设置吧,别名可以在SQL Explorer中设置
      

  3.   

    object frmlogin: Tfrmlogin
      Left = 335
      Top = 180
      Width = 362
      Height = 301
      BorderIcons = [biSystemMenu]
      Caption = #29992#25143#30331#38470
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnClose = FormClose
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Label2: TLabel
        Left = 72
        Top = 85
        Width = 81
        Height = 16
        Caption = #29992' '#25143' '#21495#65306'         '
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clBlack
        Font.Height = -13
        Font.Name = 'MS Sans Serif'
        Font.Style = []
        ParentFont = False
      end
      object Label3: TLabel
        Left = 72
        Top = 119
        Width = 84
        Height = 16
        Caption = #23494'       '#30721#65306'         '
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clBlack
        Font.Height = -13
        Font.Name = 'MS Sans Serif'
        Font.Style = []
        ParentFont = False
      end
      object Bevel1: TBevel
        Left = 48
        Top = 8
        Width = 265
        Height = 50
        Shape = bsBottomLine
      end
      object Label1: TLabel
        Left = 55
        Top = 16
        Width = 298
        Height = 37
        Caption = #23398#29983#31649#29702#31995#32479'    '
        Font.Charset = GB2312_CHARSET
        Font.Color = clBlack
        Font.Height = -37
        Font.Name = #23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Button1: TButton
        Left = 64
        Top = 176
        Width = 65
        Height = 25
        Caption = #30331#38470
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clBlue
        Font.Height = -16
        Font.Name = #21326#25991#26032#39759
        Font.Style = []
        ParentFont = False
        TabOrder = 0
        OnClick = Button1Click
      end
      object Button2: TButton
        Left = 192
        Top = 176
        Width = 57
        Height = 25
        Caption = #36864#20986
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clBlue
        Font.Height = -16
        Font.Name = #21326#25991#34892#26999
        Font.Style = []
        ParentFont = False
        TabOrder = 1
        OnClick = Button2Click
      end
      object edtuserID: TEdit
        Left = 144
        Top = 80
        Width = 121
        Height = 21
        ImeName = #20013#25991' ('#31616#20307') - '#26234#33021' ABC'
        MaxLength = 11
        TabOrder = 2
        OnKeyDown = edtuserIDKeyDown
      end
      object edtpasswd: TEdit
        Left = 144
        Top = 115
        Width = 121
        Height = 21
        ImeName = #20013#25991' ('#31616#20307') - '#26234#33021' ABC'
        MaxLength = 8
        PasswordChar = '*'
        TabOrder = 3
        OnKeyDown = edtpasswdKeyDown
      end
      object Database1: TDatabase
        AliasName = '学生'
        DatabaseName = 'dbuser'
        LoginPrompt = False
        SessionName = 'Default'
        Left = 8
        Top = 56
      end
      object queryuser: TQuery
        DatabaseName = 'dbuser'
        Left = 8
        Top = 88
      end
    end
      

  4.   

    没有设置ODBC吧,设置一下ODBC,数据库别名为dbuser
      

  5.   

    设了,别名也设了。
    我telnet连接不到自己的1433端口,是哪里出问题了啊。。
      

  6.   

    设了odbc了,在系统dsn里设了数据源名称为student,并把默认数据库设成我自己的了。
    不过我telnet不到自己的1433端口,到底出什么问题了啊。。
      

  7.   


    ado的话,源码又要更改,而且不太会用ado连sql server
      

  8.   

    这是早几年,用BDE写的连接代码,你参考下
      Db.DriverName := 'MSSQL';
      DB.Params.Values['Host Name'] := '192.168.1.;
      Db.Params.Values['Server Name'] := '192.1681';
      DB.Params.Values['DataBase Name'] := 'mystock';
      DB.Params.Values['user name'] := 'sa';
      DB.Params.Values['Password'] := 'sa';
      Db.LoginPrompt := false;
      db.KeepConnection := true;
      try
        DB.Connected ;
      except
        on E : EDBEngineError do
          Raise Exception.Create(E.Message);
      end;
      

  9.   


      Db.DriverName := 'MSSQL';
      DB.Params.Values['Host Name'] := '192.168.1.;
      Db.Params.Values['Server Name'] := '192.1681';
      DB.Params.Values['DataBase Name'] := 'mystock';
      DB.Params.Values['user name'] := 'sa';
      DB.Params.Values['Password'] := 'sa';
      Db.LoginPrompt := false;
      db.KeepConnection := true;
      try
        DB.Connected ;
      except
        on E : EDBEngineError do
          Raise Exception.Create(E.Message);
      end;