Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Feb 2010
    Gender
    Female
    Posts
    129

    Default unsa may problema ani ako code? dili jud ko kaupdate


    Private Sub cmdINSERT_Click()



    Dim rs As New ADODB.Recordset
    Dim sqlstr As String
    If newedit = 0 Then


    sqlstr = "insert into DRUG values('" & Text1.Text & "', '" & Text2.Text & "','" & Val(Text3.Text) & "','" & Val(Text4.Text) & "','" & Text5.Text & "','" & Text6.Text & "','" & Val(Text7.Text) & "')"
    rs.Open "select * from DRUG where NDCNO = '" & Text1.Text & "'", Conn, adOpenDynamic, adLockOptimistic

    If rs.EOF Then
    rs.Close
    rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic
    MsgBox "New DRUG's Information Saved", vbInformation + vbOKOnly, "Saved"

    Unload Me
    Form1.Show
    cleartextBOXES
    Else

    MsgBox "Error: Duplicate NDCNO NUMBER!", vbInformation, "ERROR"


    Text1.Enabled = True
    controltextboxes (True)
    Text1.SetFocus
    cmdedit.Enabled = False
    cmdINSERT.Enabled = True
    exitErr:
    Exit Sub
    errSave:
    Conn.RollbackTrans
    MsgBox "ERROR:" & Err.Description, vbCritical
    Resume exitErr
    End If

    Else
    sqlstr = "Update DRUG Set NAME_STR='" & Text2.Text & "', UNIT='" & Text3.Text & "', PKG_QTY='" & Text4.Text & "', LEGAL_CLS='" & Text5.Text & "', THERA_CLS='" & Text6.Text & "', AWP='" & Text7.Text & "', where NDCNO ='" & Text1.Text & "' "
    ' rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic

    'rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic
    MsgBox "Employee's Information Updated", vbInformation + vbOKOnly, "Updated"


    cleartextBOXES

    End If
    populateFlexGrid
    controltextboxes (False)
    cmdINSERT.Enabled = True

    End Sub


    here is my table datatype
    CREATE TABLE DRUG (NDCNO CHAR(5) NOT NULL PRIMARY KEY,
    NAME_STR VARCHAR(30) NOT NULL,
    UNIT INT( NOT NULL,
    PKG_QTY INT( NOT NULL,
    LEGAL_CLS CHAR(3) NOT NULL,
    THERA_CLS CHAR(10) NOT NULL,
    AWP DECIMAL(8,2) NOT NULL)

  2. #2
    i-zip imong project then i-upload unya i-share ang download link dri para matan-aw sa motabang.

  3. #3
    Quote Originally Posted by mcapon View Post
    Private Sub cmdINSERT_Click()



    Dim rs As New ADODB.Recordset
    Dim sqlstr As String
    If newedit = 0 Then


    sqlstr = "insert into DRUG values('" & Text1.Text & "', '" & Text2.Text & "','" & Val(Text3.Text) & "','" & Val(Text4.Text) & "','" & Text5.Text & "','" & Text6.Text & "','" & Val(Text7.Text) & "')"
    rs.Open "select * from DRUG where NDCNO = '" & Text1.Text & "'", Conn, adOpenDynamic, adLockOptimistic

    If rs.EOF Then
    rs.Close
    rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic
    MsgBox "New DRUG's Information Saved", vbInformation + vbOKOnly, "Saved"

    Unload Me
    Form1.Show
    cleartextBOXES
    Else

    MsgBox "Error: Duplicate NDCNO NUMBER!", vbInformation, "ERROR"


    Text1.Enabled = True
    controltextboxes (True)
    Text1.SetFocus
    cmdedit.Enabled = False
    cmdINSERT.Enabled = True
    exitErr:
    Exit Sub
    errSave:
    Conn.RollbackTrans
    MsgBox "ERROR:" & Err.Description, vbCritical
    Resume exitErr
    End If

    Else
    sqlstr = "Update DRUG Set NAME_STR='" & Text2.Text & "', UNIT='" & Text3.Text & "', PKG_QTY='" & Text4.Text & "', LEGAL_CLS='" & Text5.Text & "', THERA_CLS='" & Text6.Text & "', AWP='" & Text7.Text & "', where NDCNO ='" & Text1.Text & "' "
    ' rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic

    'rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic
    MsgBox "Employee's Information Updated", vbInformation + vbOKOnly, "Updated"


    cleartextBOXES

    End If
    populateFlexGrid
    controltextboxes (False)
    cmdINSERT.Enabled = True

    End Sub


    here is my table datatype
    CREATE TABLE DRUG (NDCNO CHAR(5) NOT NULL PRIMARY KEY,
    NAME_STR VARCHAR(30) NOT NULL,
    UNIT INT( NOT NULL,
    PKG_QTY INT( NOT NULL,
    LEGAL_CLS CHAR(3) NOT NULL,
    THERA_CLS CHAR(10) NOT NULL,
    AWP DECIMAL(8,2) NOT NULL)
    kani itry.

    conn.execute "Update DRUG Set NAME_STR='" & Text2.Text & "', UNIT='" & Text3.Text & "', PKG_QTY='" & Text4.Text & "', LEGAL_CLS='" & Text5.Text & "', THERA_CLS='" & Text6.Text & "', AWP='" & Text7.Text & "', where NDCNO ='" & Text1.Text & "' "
    msgbox "Update successfully"

    try lang ni

    sa ibm2 na no

    klaro au.

  4. #4
    sqlstr = "Update DRUG Set NAME_STR='" & Text2.Text & "', UNIT=" & Text3.Text & ", PKG_QTY=" & Text4.Text & ", LEGAL_CLS='" & Text5.Text & "', THERA_CLS='" & Text6.Text & "', AWP=" & Text7.Text & ", where NDCNO ='" & Text1.Text & "' "

    'bro, basta int or decimal ang datatype, wla nay single quote s sql statement..
    'suggestion lang sab bro, varchar gamita instead of char..
    'icompare lang bro, mkbalo ra u nganu kana ako suggestion..

  5. #5
    bro, itry daw butangi ug val kung asa to na assign ang textbox intended for int or decimal, and try also parameterized update every field isulod ug ing ani [name_str], try ni bro

  6.    Advertisement

Similar Threads

 
  1. unsa pag repair ani hdd 1tb dili siya 100% execellent
    By ryan101@yahoo.com in forum Computer Hardware
    Replies: 11
    Last Post: 03-04-2012, 04:45 PM
  2. unsa problema ani ako pc core speed?
    By bunal69 in forum Computer Hardware
    Replies: 14
    Last Post: 12-25-2011, 03:27 PM
  3. HD unsa kaha problema ani?
    By dcshoeboy in forum Windows Software
    Replies: 9
    Last Post: 03-25-2011, 10:19 PM
  4. Replies: 66
    Last Post: 06-24-2010, 08:37 PM
  5. Replies: 8
    Last Post: 03-02-2006, 04:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top