一直都是做.NET开发的 前天接一delphi项目  
昨天刚接触delphi,今天boss就让学数据连接 希望前辈们能给点提示
我希望前辈们能写出来发到我的邮箱
我只是想快点入门  谢谢。
数据库用4个字段 id,name,sex,age
有4个edit (附有图片,双击应该能看大图)
查询的时候在 edit1 中输入 id号 就可以把结果显示在对应name...字段的edit中 
删除
更改
增加
显示全部的按钮的事件就不用写了恩 怎么样才能从edit输入,然后查询的内容显示到dbgrid中?
谢谢。

解决方案 »

  1.   

    adoconnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=318087;Persist Security Info=True;User ID=sa;Initial Catalog=MFD;Data Source=172.20.104.41';
          adoconnection1.LoginPrompt :=false;
          adoconnection1.Connected :=true;
      

  2.   

    procedure TAdduserForm.bsSkinButton1Click(Sender: TObject);
    var
      uid,name,password,state, authority : String;
      i : Integer;
    begin
      //增加用户
      uid := bsSkinEdit1.Text;
      password := MD5Print(MD5String(bsSkinPasswordEdit1.Text));
      //password := bsSkinPasswordEdit1.Text;
      name := bsSkinEdit2.Text;
      state := IntToStr(bsSkinComboBox1.ItemIndex);
      if buttonstate=1 then
      begin
        authority := '';
        for i:=0 to bsSkinCheckListBox1.Items.Count-1 do
        begin
          if  bsSkinCheckListBox1.Checked[i] = True then
            authority := authority + '1'
          else
            authority := authority + '0';
        end;    if uid = ''  then
        begin
          MessageBox(Handle, '请输入登录名称!', '提示', MB_ICONASTERISK);
          bsSkinEdit1.SetFocus;
          exit;
        end;    if name = ''  then
        begin
          MessageBox(Handle, '请输入操作员姓名!', '提示', MB_ICONASTERISK);
          bsSkinEdit2.SetFocus;
          exit;
        end;    if bsSkinPasswordEdit1.Text = ''  then
        begin
          MessageBox(Handle, '请输入密码!', '提示', MB_ICONASTERISK);
          bsSkinPasswordEdit1.SetFocus;
          exit;
        end;    if bsSkinPasswordEdit1.Text  <> bsSkinPasswordEdit2.Text  then
        begin
          MessageBox(Handle, '密码与密码确认不一致,请重新输入密码!', '提示',
            MB_ICONASTERISK);
          exit;
        end;    DSQuery := TSDQuery.Create(nil);
        DSQuery.DatabaseName := 'timecarddb';
        DSQuery.SQL.Clear;
        DSQuery.SQL.Add( 'select * from operatorstb where uid='+quotedstr(uid));
        try
          DSQuery.Open;
        if not DSQuery.Eof then
        begin
           MessageBox(Handle, '输入的登录名称已经存在,请重新输入!', '提示',
            MB_ICONASTERISK);
            exit;
        end else
          DSQuery.Close;
          DSQuery.SQL.Clear;
          DSQuery.SQL.Add( 'insert into operatorstb (uid,password,name,authority,'+
          'state) values ('+quotedstr(uid)+',('+quotedstr(password)+'),'+
          quotedstr(name)+','+quotedstr(authority)+','+quotedstr(state)+')');
          DSQuery.ExecSQL();
          MessageBox(Handle, '添加用户成功!', '提示',
            MB_ICONASTERISK);
          DSQuery.Close;
        finally
          DSQuery.Free;
        end;
        //SetsystemForm.UserShow;
        SetSystermForm.OperatorsShow;
        Close;
      end;