我晕,学校做过一个系统,但是现在忘了怎么弄。我现在想做个报价表,能通过产品名称查询产品信息及价格。可以修改、添加、删除、保存产品信息。谁能有个添加、删除等功能的实例啊,不一定要一样,像学校里做的学生表查询差不多实例给我就行,我主要是有些语句忘了。

解决方案 »

  1.   

    Private Function AddSiteType(sName As String, x As String, y As String, sGroup As String, sTm As String) As Boolean
        
    On Error GoTo GetERR
    Dim sData(4), s, sCmd As String    Set EF = New ADODB.Recordset
        Set EF = oCmn.ExecRS(sTm, DCN)
        If Not (EF.EOF And EF.BOF) Then
            AddSiteType = False
            MsgBox "Sorry,¡¾" & sName & "¡¿already exist,input another name£¿  ", vbExclamation
        Else
            sData(0) = GetTableID("tables")
            sData(1) = sName
            sData(2) = x
            sData(3) = y
            sData(4) = sGroup
            s = Join(sData, "','")
            sCmd = "insert into tables (TableID,TableName,x,y,TableGroupID) " & "VALUES ('" & s & "')"
            oCmn.ExecSql sCmd, DCN
            AddSiteType = True
        End If
           
        Exit Function
    GetERR:
        MsgBox "add site error:" & Err.Description, vbCritical
         
    End Function
    Private Function EditSiteType(sName As String, sOldName As String, sSql As String, x As String, y As String, sGroup As String) As Boolean
      
    On Error GoTo GetERR    Set EF = New ADODB.Recordset
        If UCase(sName) <> UCase(sOldName) Then
            Set EF = New ADODB.Recordset
            EF.Open "Select * from Tables Where TableName='" & sName & "'", DCN, adOpenStatic, adLockReadOnly, adCmdText
            If Not (EF.EOF And EF.BOF) Then
                EF.close
                Set EF = Nothing
                EditSiteType = False
                MsgBox "Sorry,¡¾" & sName & "¡¿exist!", vbExclamation
                Exit Function
            End If
            EF.close
            Set EF = Nothing
        End If
           
        EF.Open sSql, DCN, adOpenStatic, adLockOptimistic, adCmdText
        If EF.EOF And EF.BOF Then
            EditSiteType = False
            MsgBox "Sorry,¡¾" & sOldName & "¡¿not exist,Edit Error£¿  ", vbExclamation
        Else
           If EF("SiteStatus") = 2 Then
               EF.close
               Set EF = Nothing
               EditSiteType = False
               MsgBox "¡¾" & sName & "¡¿is using,can't edit¡£Please edited after checkout.", vbExclamation
               Exit Function
           End If
           EF("TableName") = sName
           EF("X") = x
           EF("Y") = y
           EF("TableGroupID") = sGroup
           EF.Update
              
           EditSiteType = True
        End If
        EF.close
        Set EF = Nothing
           
        Exit Function
    GetERR:
        EditSiteType = False
        MsgBox "Save Error:" & Err.Description, vbCritical
       
    End Function
    Public Function DeleteSiteType(sName As String, sTable As String) As Boolean
      
    On Error GoTo GetERR
    Dim oRs As New ADODB.Recordset
    Dim nNo, sCmd As String    Set EF = New ADODB.Recordset    EF.Open "Select * from Tables Where  TableName='" & sName & "'", DCN, adOpenStatic, adLockReadOnly, adCmdText
        If EF.EOF And EF.BOF Then
            EF.close
            Set EF = Nothing
            DeleteSiteType = True
            Exit Function
        Else
           If EF("SiteStatus") > 0 Then
               EF.close
               Set EF = Nothing
               DeleteSiteType = False
               MsgBox "Sorry,Table has been available or Reserved,can't deleted£¿  ", vbInformation
               Exit Function
           End If
        End If
        DCN.Execute "Delete From " & sTable & " Where TableName='" & sName & "'"
       
        'update TableRunningNO
        Set oRs = New ADODB.Recordset
        sCmd = "select * from tables order by tableID desc limit 1"
        oRs.Open sCmd, DCN, adOpenStatic, adLockOptimistic, adCmdText
        nNo = oRs.Fields("tableID")
        oRs.close
        Set oRs = Nothing
       
        sCmd = "Update RunningNumber set "
        sCmd = sCmd & "RunningNo=" & nNo
        sCmd = sCmd & " Where "
        sCmd = sCmd & " ModuleName='" & sTable & "'"
        oCmn.ExecSql sCmd, DCN
       
        EF.close
        Set EF = Nothing
        DeleteSiteType = True
           
        Exit Function
    GetERR:
        DeleteSiteType = False
        MsgBox "Del Error:" & Err.Description, vbCritical
       
    End Function
      

  2.   

    谢谢二楼的哈,还是知道我说的意思,但是我不要用c编是用vb编的。
      

  3.   

    http://download.csdn.net/source/1498324
      

  4.   

    下面这个一定能满足您的要求:
    http://xueban69.download.csdn.net/
      

  5.   

    对不起,从这里进去更快:
    http://download.csdn.net/source/1887292
      

  6.   

    网上这类代码一大堆,Google一下试试看。