现源码如下:
Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset'sql server数据库连接过程
Cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=UFDATA_002_2011;Data Source=192.168.1.16;Connect Timeout=30"
Cn.Open
'***********下面是SQL语句部分strsql = " select poa.cpoid as 订单号,poa.dpodate as 日期,pob.cinvcode as 物料编码,inventory.cinvname as 物料名称,pob.iquantity as 订单数,pob.ireceivedqty as 到货数,pob.iunitprice as 单价 ,pob.imoney as 金额 from po_pomain poa  inner join po_podetails pob  on poa.poid=pob.poid left join inventory on pob.cinvcode=inventory.cinvcode where poa.cpoid='PO" & Text1.Text & "' " & strWhere'************
If Cn.State = adStateOpen Then
  Rs.CursorLocation = adUseClient
  Rs.Open strsql, Cn, adOpenDynamic, adLockOptimistic
Else
  MsgBox "SQL Server数据库连接错误!"
  End
End IfSet DataGrid1.DataSource = Rs
Set Rs = Nothing现在要做的是在查询后显示数据的控件里删除选中的整行
然后数据库的po_podetails表里的对应行也要删掉,其它的表不动郁闷,怎么只有85分了
谢谢各大侠指点、、、、、、、、、

解决方案 »

  1.   

    继续对po_podetails表进行条件删除嘛
    http://download.csdn.net/source/1644211
      

  2.   


    '先删除
    myid = Val(Trim(DataGrid1.Columns(0))) '到DataGrid1的当前行的第一列的值,也就是订单号'根据订单号,删除相应记录
    Rs.Open "delete from po_podetails where cpoid='" & myid & "'", Cn, adOpenDynamic, adLockOptimistic'重新显示
    strsql = " select poa.cpoid as 订单号,poa.dpodate as 日期,pob.cinvcode as 物料编码,inventory.cinvname as 物料名称,pob.iquantity as 订单数,pob.ireceivedqty as 到货数,pob.iunitprice as 单价 ,pob.imoney as 金额 from po_pomain poa  inner join po_podetails pob  on poa.poid=pob.poid left join inventory on pob.cinvcode=inventory.cinvcode where poa.cpoid='PO" & Text1.Text & "' " & strWhere'************
    If Cn.State = adStateOpen Then
      Rs.CursorLocation = adUseClient
      Rs.Open strsql, Cn, adOpenDynamic, adLockOptimistic
    Else
      MsgBox "SQL Server数据库连接错误!"
      End
    End IfSet DataGrid1.DataSource = Rs
    Set Rs = Nothing