how to add data to database ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gillian3114
    New Member
    • Mar 2007
    • 16

    how to add data to database ?

    i dont want use insert sql query
    got other way to do ?

    Code:
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strCNString As String
    
    strCNString = "Data Source=" & App.Path & "\final.mdb"
    cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
    cn.ConnectionString = strCNString
    cn.Open
    
    Dim sql As String
        sql = "SELECT sum(salary), name, gender FROM abc GROUP BY name, gender"
        Set rs = cn.Execute(sql, , adCmdText)
    
          With rs
          
            .Fields("salary").Value = txtSalary.Text        
            .Fields("name").Value = txtName.Text
            .Fields("gender").Value = txtGender.Text
            
          End With
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by gillian3114
    i dont want use insert sql query
    got other way to do ?

    Code:
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strCNString As String
    
    strCNString = "Data Source=" & App.Path & "\final.mdb"
    cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
    cn.ConnectionString = strCNString
    cn.Open
    
    Dim sql As String
        sql = "SELECT sum(salary), name, gender FROM abc GROUP BY name, gender"
        Set rs = cn.Execute(sql, , adCmdText)
    
          With rs
          
            .Fields("salary").Value = txtSalary.Text        
            .Fields("name").Value = txtName.Text
            .Fields("gender").Value = txtGender.Text
            
          End With
    How do you mean? I am certain there are many ways to retrieve with minimal coding. I can't see how this can be achieved without writing actual SQL, especially if you are looking at grabbing data out of database columns, rows, and so on. Please continue to stay tuned, other, more qualified specialists here may know of some tricks that'll help you through...

    Comment

    Working...