Validate data in a table
-
I have entered data into a database table, "PersonData". It has 5 columns PersonNo Sex Age Married Education. Now I want to write a validation program in vb whereby it opens the "PersonData" and then checks that if person is married, then the spouse has to be of different sex. and if the pesron is married then the age has to be more than 15. There are many incosistencies that I would like my code to check, but if I can be helped with this ones I can handle the others. This I want to run for say about a thousands records. Then I write the validation messages to a text file. This is a sample of the code I have written: Option Explicit Public objConn As ADODB.Connection Public objRst As ADODB.Recordset Public objPwd As ADODB.Recordset Public objCmd As ADODB.Command Public Sub main() Set objConn = New ADODB.Connection Set objRst = New ADODB.Recordset Set objCmd = New ADODB.Command objConn.Provider = "MSDASQL.1" objConn.ConnectionString = "Password=pwdsa;Persist Security Info=True;User ID=idsa;Data Source=TESTING;Initial Catalog=TESTING" objConn.Open If objConn.State = adStateOpen Then MsgBox "Connexion with the server established", vbInformation, "prjTesting" Else MsgBox "Connexion Failed !", vbInformation, "prjTesting" End If End Sub Private Sub cmdValidate_Click() Open "C:\Testing\testing.txt " For Output As #1 With objRst Do While Not .EOF if !married = 1 and !age < 15 then write #1, "PersonID: "; !personid & " " Person must be greater 15 years in order to be married" .MoveNext Loop End With End Sub Private Sub Form_Load() main Set objRst = New ADODB.Recordset objRst.Open "tblPersondata", objConn, adOpenDynamic, adLockOptimistic End Sub ----------------------------- The problem with my code is that, it only checks for the first column only as with the other columns it does not. What am I doing wrong. Quick Help is appreciated. Thank you:(( phokojoe
-
I have entered data into a database table, "PersonData". It has 5 columns PersonNo Sex Age Married Education. Now I want to write a validation program in vb whereby it opens the "PersonData" and then checks that if person is married, then the spouse has to be of different sex. and if the pesron is married then the age has to be more than 15. There are many incosistencies that I would like my code to check, but if I can be helped with this ones I can handle the others. This I want to run for say about a thousands records. Then I write the validation messages to a text file. This is a sample of the code I have written: Option Explicit Public objConn As ADODB.Connection Public objRst As ADODB.Recordset Public objPwd As ADODB.Recordset Public objCmd As ADODB.Command Public Sub main() Set objConn = New ADODB.Connection Set objRst = New ADODB.Recordset Set objCmd = New ADODB.Command objConn.Provider = "MSDASQL.1" objConn.ConnectionString = "Password=pwdsa;Persist Security Info=True;User ID=idsa;Data Source=TESTING;Initial Catalog=TESTING" objConn.Open If objConn.State = adStateOpen Then MsgBox "Connexion with the server established", vbInformation, "prjTesting" Else MsgBox "Connexion Failed !", vbInformation, "prjTesting" End If End Sub Private Sub cmdValidate_Click() Open "C:\Testing\testing.txt " For Output As #1 With objRst Do While Not .EOF if !married = 1 and !age < 15 then write #1, "PersonID: "; !personid & " " Person must be greater 15 years in order to be married" .MoveNext Loop End With End Sub Private Sub Form_Load() main Set objRst = New ADODB.Recordset objRst.Open "tblPersondata", objConn, adOpenDynamic, adLockOptimistic End Sub ----------------------------- The problem with my code is that, it only checks for the first column only as with the other columns it does not. What am I doing wrong. Quick Help is appreciated. Thank you:(( phokojoe
-
Actually, What i am saying is that, the data is already in the database. Now the code I am writing will look for the inconsistencies and then write the message to the .txt file that I have specified with the ID of that particular person where there is incosistancies. In this, below Private Sub cmdValidate_Click() Open "C:\test\persondata.txt " For Output As #1 With objRst Do While Not .EOF If !married = 1 and age < 15 Then Write #1, "Person ID: "; !personid & " Too young to get married" .MoveNext Loop End With End Sub For the married code is 1 and I am checking that if that particular person is married then, his/her age must be greater than 15 otherwise write down the personid in the persondata.txt file so that it will be corrected. Since I will be checking many persons and the same time that is why I have enclosed the statement inside the DO WHILE NOT EOF. Please help phokojoe
-
Actually, What i am saying is that, the data is already in the database. Now the code I am writing will look for the inconsistencies and then write the message to the .txt file that I have specified with the ID of that particular person where there is incosistancies. In this, below Private Sub cmdValidate_Click() Open "C:\test\persondata.txt " For Output As #1 With objRst Do While Not .EOF If !married = 1 and age < 15 Then Write #1, "Person ID: "; !personid & " Too young to get married" .MoveNext Loop End With End Sub For the married code is 1 and I am checking that if that particular person is married then, his/her age must be greater than 15 otherwise write down the personid in the persondata.txt file so that it will be corrected. Since I will be checking many persons and the same time that is why I have enclosed the statement inside the DO WHILE NOT EOF. Please help phokojoe
Please help me with the above thread. Help is urgently needed. Actual, I am writing a code to validate my survey results whichI have used MS sql server 2000 as the backend and VB as the front end. Or can anybody help me with which is the appropriate software to use to validate the dataset. phokojoe