Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 Oracle
Private Sub SAVE_Click()
Dim SQL As String
'If Combo4.Text = 121 Then
SQL = "UPDATE STUDENT_RECORD_DATABASE "
SQL = SQL + " SET ROLLNO= " & Val(Combo4) & ","
SQL = SQL + "FIRST_NAME= '" & Trim(Text2) & "',"
SQL = SQL + "MIDDLE_NAME= '" & Trim(Text3) & "',"
SQL = SQL + "LAST_NAME= '" & Trim(Text4) & "',"
SQL = SQL + "CONTACT=" & Val(Text5) & ","
SQL = SQL + "CONTACT1=" & Val(Text6) & ","
SQL = SQL + "CONTACT2=" & Val(Text7) & ","
SQL = SQL + "ADDRESS= '" & Trim(Text8) & "',"
SQL = SQL + "GRADE='" & Val(Combo1) & "',"
THIS CODE WILL WORK?  SQL = SQL + "DIVID='" & Val(Combo2) & "'"
OR THIS ONE-    'SQL = SQL + "SELECT * FROM DIVISION WHERE DIV='" & Combo2.Text & "',"
SQL = SQL + "BLOOD_GROUP='" & Val(Combo3) & "',"
THIS CODE WILL WORK?  SQL = SQL + "HID='" & Val(Combo9) & "',"
OR THIS ONE-    'SQL = SQL + "SELECT * FROM HNM WHERE HOUSE='" & Val(Combo9) & "',"
SQL = SQL + "TRANSPORT='" & Val(Combo10) & "',"
SQL = SQL + "SNAME='" & Val(Combo5) & "',"
SQL = SQL + "MEAL='" & Val(Combo11) & "',"
SQL = SQL + "BUSNO='" & Val(Combo6) & "',"
SQL = SQL + "RUTNO=" & Val(Combo12) & ","
THIS CODE WILL WORK?  SQL = SQL + "DID='" & Val(Combo7) & "'"
OR THIS ONE-    'SQL = SQL + "SELECT *FROM DRIVER WHERE DNAME='" & Val(Combo7) & "',"
THIS WILL WORK?  SQL = SQL + "AID='" & Val(Combo8) & "'"
OR THIS WILL-   'SQL = SQL + "SELECT * FROM ATTEND WHERE ANM='" & Val(Combo8) & "',"
SQL = SQL + "CARD_TYPE='" & Val(Combo13) & "',"
SQL = SQL + "CARD_NO=" & Val(Text11) & ""
SQL = SQL + "WHERE ROLLNO= " & Val(Combo4) & ""
CON.Execute (SQL)
'RES.Update
    MsgBox ("RECORD UPDATED")
 
ELSE
SQL = "INSERT INTO STUDENT_RECORD_DATABASE WHERE ROLLNO=" & Combo4.Text
   SQL = SQL + "VALUES (" & Val(Combo4.Text) & ","
        SQL = SQL + "" & Trim(Val(Text3.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text4.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text5.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text6.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text7.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text8.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo1.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo2.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo3.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo9.Text)) & ","
        SQL = SQL + "" & Val(DTPicker1) & ","
        SQL = SQL + "" & Trim(Val(Combo10.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo5.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo11.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo6.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo12.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo7.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo8.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text9.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text10.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo13.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text11.Text)) & ")"
'End If
End Sub
 
This code is not working properly.
Many kind of errors occur while running this code
Please help.
 
[Edit]Shouting removed[/Edit]
Posted 21-Dec-12 23:15pm
surkhi623
Edited 22-Dec-12 0:05am
ProgramFOX131.6K
v2
Comments
Sandeep Mewara at 22-Dec-12 5:12am
   
It would be better if you share what are you trying to do and what all error you are getting in your implementation.
Member 9687206 at 22-Dec-12 5:26am
   
i want to do two operations using a single button i.e save. by clicking in save button it will check for existing rollno or new one.if rollno already exist it will update that record otherwise create a new record.
i am having 121,122,123,124 rollnos already in my table.
for little changes it shows errors like: 1.sql command not properly ended
2.parent key not found
3.invalid database.table.column name
or just shows msgbox- record updated but not updating the record actually
what sh'd i do?????? please help

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try to fire your query in a sql management studio like sql express 2008. Be sure that your syntax is correct. if it is, the errors show you what to do...
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 230
1 PIEBALDconsult 150
2 DamithSL 125
3 BillWoodruff 108
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100