先根据每行和每例定位到数据库中。如有则updat否者,insert
要用到stringgrid.cells[x,y],row,col等信息。

解决方案 »

  1.   

    如果用StringGrid就没有必要用存储过程,
    你可以用Query啊,
      

  2.   

    先谢谢楼上的,我不想在程式中判断,想在存储过程中写,应如何写?
    是不是
    if exists select * from 表1 where 表1.日期=日期 表1.卡号=卡号
    then
    update......
    else
    insert into .....
    我以前没写过存储过程,请指教
      

  3.   

    这只是保存一个员工一天的过程,
    你只要循环调用就可以了!
    print 'create procedure ow_sav_working ...'if exists (select * from sysobjects where id = object_id('dbo.ow_sav_working') and sysstat & 0xf = 4)
    drop procedure dbo.ow_sav_working
    GOcreate procedure ow_sav_working
      @Code varchar(16),--卡号
      @Date char(8),
      @Class char(1)--班次
    as
    begin
        if (exists(select * from [表] where [Code]=@Code and [Date]=@Date))
          Update [表] set [Class]=@Class where [Code]=@Code and [Date]=@Date
        else
          Insert [表] values(@Code,@Date,@Class)
        if @@rowcount<>1 then
          return = -1--失败
       
      return 0
    endGO
      

  4.   

    TO hzlan(hzlan) 定义好变量后,就按照你的方法没错。用ADOSTOREDPROC调用存储过程即可。