博客统计信息

用户名:lucky1
文章数:15
评论数:39
访问量:50558
无忧币:20
博客积分:709
博客等级:2
注册日期:2007-03-06

我最近发表的评论

如何用delphi做信.. 回复
估计你数据库没有连接吧
高斯列主元消去法.. 回复
解线性方程组
如何用delphi做信.. 回复
用access代码基本一样,只是在用ADO..
如何用delphi做信.. 回复
Java我不是很熟悉,曾经稍微学过点..
如何用delphi做信.. 回复
直接退出程序啊

背景音乐

我的音乐

00:00 | 00:00

    最近初学delphi,用它做了一个图书馆信息管理系统,现在把登陆窗口代码发上来,希望对初学者能少许帮助.
    先把界面发上来,如下图所示:
   
   步骤:
    1.新建一个窗体,在窗体中放置上图所示组建.
    2.连接数据库.选中ADOQuery1组建,点击左侧ConnectionString属性右侧的省略号,在弹出对话框中点击Build,再在弹出框中选择Microsoft OLE DB Provider for SQL Sever,点击"下一步",在新弹出的窗口中选择"使用Windows NT 继承安全设置"(当然,如果你的SQL安装时有用户名和密码则选择下面那个),然后在服务器上数据库下拉框中选择你要连接的数据库,最后一路确定即可.其他选项暂时可不用管它.
   3.写代码.双击"登陆",写如下代码
   procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  try
    with adoquery1 do
    begin
      close;
      sql.clear;
      sql.add('select * from user_master where 用户名=:a and 密码=:b and 权限=:c');
      parameters.ParamByName('a').Value:=trim(combobox1.Text);
      parameters.ParamByName('b').Value:=trim(edit1.Text);
      if combobox1.Text ='' then
        begin
          application.MessageBox('请输入用户名','提示信息',64);
          combobox1.SetFocus;
          exit;
        end;
      if edit1.Text ='' then
        begin
          application.MessageBox('请输入密码','提示信息',64);
          edit1.SetFocus;
          exit;
        end;
      if radiobutton1.Checked=true then
        begin
          Quanxian:='1';
        end;
      if radiobutton2.Checked=true then
        begin
          Quanxian:='0';
        end;
      parameters.ParamByName('c').Value:=trim(quanxian);
      open;
      end;
      if adoquery1.RecordCount<>0 then
        begin
          Username:=combobox1.Text;
          Password:=edit1.Text;
          application.MessageBox('登陆成功','提示信息',64);
          form2.show;
          self.Hide;
        end
      else
        application.MessageBox('输入的用户名或密码错误','提示信息',64);
  except
    application.MessageBox('登陆失败','提示信息',64);
  end;
end;
 
    4.为了让用户在第一次使用管理系统时数据库文件可自动附加到SQL服务器中,可双击窗体空白部分,加入一下代码:
    procedure TForm1.FormCreate(Sender: TObject);
var
   ADOCommand:TADOCommand;
   s,DataPath : string;
begin
   adoConnection1:=TADOConnection.Create(nil);
   adoConnection1.ConnectionString:='Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=library';
   adoConnection1.LoginPrompt:=false;
   try
     adoConnection1.Connected:=true;
   except
     ADOCommand:=TADOCommand.Create(nil);
     ADOCommand.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False';
     DataPath:=ExtractFilePath(Application.ExeName) ;
     s:='EXEC sp_attach_db @dbname = N'+char(39)+'library'+char(39)+','+
        '@filename1 = N'+char(39)+DataPath+'library_Data.MDF'+char(39)+
          ','+'@filename2 = N'+char(39)+DataPath+'library_Log.LDF'+char(39);
     ADOCommand.CommandText := s;
     ADOCommand.Execute();
   end;
end;
    [/img]..
2007-04-11 13:43:14
1.查询模块:
Public Function Exesql(ByVal sql As String, msgstring As String) As ADODB.Recordset
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
On Error GoTo runsql_error
cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=student"
cn.Open
cmd.ActiveConnection = cn
cmd.CommandType = adCmdText
cmd.CommandText = sql
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adL..
2007-03-06 22:06:51
#include<stdio.h>
#include<math.h>
 
double f(double x,double y)
{
   return y-2*x/y;
}
 
double R_K(a,b,y0,N)
   double a,b,y0;
   int N;
{
   double x,y,h,K1,K2,K3,K4;
   int k;
   h=(b-a)/N;
   x=a;
   y=y0;
   printf("x=%f,y=%f,",x,y);
   printf("f(x)=%f\n",sqrt(1+2*x));
   for(k=1;k<=N;k++)
   {
     K1=..
类别:C/C++|阅读(300)|回复(2)|(0)阅读全文>>
2007-03-06 22:06:00
#include<stdio.h>
#include<math.h>
 
double f(double x)
{
   return 4/(1+x*x);
}
 
double RombergInteg(f,a,b,eps)
   double (*f)();
   double a,b,eps;
{
   int i=1,j;
   double T[2][4],h=b-a;
   double x,s,r,det,m;
   T[0][0]=(f(a)+f(b))*h/2;
   while(1){
     s=0;
     for(x=a+h/2;x<b;x+=h) s+=f(x);
     T[1][..
类别:C/C++|阅读(430)|回复(0)|(0)阅读全文>>
 <<   1   2   3   4   >>   页数 ( 1/4 )