Results 1 to 4 of 4

Thread: how to create save function

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    8

    how to create save function

    hi everyone..i'm newbie in vb 6 and i really need helps from u guys here.
    Actually, i've 9 textboxes and 10 comboboxes in the form. what i want is when i enter Print button, the data will stored in database and in the same time it will go to new form. The link to new form is already successful. the problem now is how to create the save function??

    here i paste my code.

    Code:
    Private Sub SaveData()
        'conn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password ='999999';Data Source=(local);Initial Catalog =TGB"
        Conn2.Open
        
        cmd = "INSERT INTO DMF_ERP_TumTag(FactoryID, TTLineNo, DateTime, " _
            & "BlockNo, GloveType, TTSize, Side, Color, Texture, Length, Thickness, " _
            & "GloveWeight, BasWeight, BasBarCode, CompTankNo, BasketNo, TumblerNo, " _
            & "TumblerBoyID, Supervisor)" _
            & " VALUES ('" & cboFacId.Text & ", " & ComboBox1.Text & "," _
            & " #" & txtDateTime.Text & "#, " & Text2.Text & ", " & cboGloveType & ", " & cboSize.Text & "," _
            & " " & cboSide.Text & ", " & cboColour.Text & ", " & cboTexture.Text & ", " & cboLength & "," _
            & " " & cboThickness.Text & ", " & Text3.Text & ", " & Text1.Text & ", " & txtBarcode.Text & "," _
            & " " & Text4.Text & ", " & Text5.Text & ", " & Text6.Text & " , " & Text7.Text & ", " & Text8.Text & " ')"
        
        rs.Open cmd, adOpenStatic, adLockReadOnly
        Conn2.Execute cmd

  2. #2

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: how to create save function

    Welcome to the forums

    You don't need a Recordset for INSERT and UPDATE, only for SELECT. So it would go something like this:
    Code:
    Conn2.Open
    Conn2.Execute "INSERT..."
    Conn2.Close
    However, it's quite unusual to create a new Connection in a sub-procedure. People usually use one that's global. Just a suggestion

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    8

    Smile Re: how to create save function

    thanx gavio..i'll try this first..
    :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width