Click here to Skip to main content
15,892,746 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: A question about event handlers Pin
carloqueirolo7-May-06 21:15
carloqueirolo7-May-06 21:15 
QuestionDataGridView - SortCompare event not firing! Pin
nzmike6-May-06 18:08
nzmike6-May-06 18:08 
AnswerRe: DataGridView - SortCompare event not firing! Pin
nzmike6-May-06 20:04
nzmike6-May-06 20:04 
Questiontime stamp value Pin
_tasleem6-May-06 10:48
_tasleem6-May-06 10:48 
Questionpopulating the Combo box with database tables Pin
Hafiz_Akbar_Ali6-May-06 8:39
Hafiz_Akbar_Ali6-May-06 8:39 
Questionformat(now,"dd/mm/yyyy") not working in vb.net Pin
pptadam6-May-06 6:52
pptadam6-May-06 6:52 
AnswerRe: format(now,"dd/mm/yyyy") not working in vb.net Pin
Joshua Quick6-May-06 9:17
Joshua Quick6-May-06 9:17 
QuestionValidate data in a table Pin
phokojoe6-May-06 3:12
phokojoe6-May-06 3:12 
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 youCry | :((

phokojoe
AnswerRe: Validate data in a table Pin
mr_123456-May-06 10:04
mr_123456-May-06 10:04 
GeneralRe: Validate data in a table Pin
phokojoe7-May-06 1:32
phokojoe7-May-06 1:32 
GeneralRe: Validate data in a table Pin
phokojoe9-May-06 22:47
phokojoe9-May-06 22:47 
QuestionReading from notepad File Pin
Mr kilany6-May-06 3:08
Mr kilany6-May-06 3:08 
AnswerRe: Reading from notepad File Pin
Colin Angus Mackay6-May-06 3:15
Colin Angus Mackay6-May-06 3:15 
AnswerRe: Reading from notepad File Pin
kkppttoo7-May-06 0:49
kkppttoo7-May-06 0:49 
Questiondouble rows Pin
microuser_20006-May-06 2:03
microuser_20006-May-06 2:03 
QuestionCopy Objects - Am I missing something? Pin
Kaditcher6-May-06 1:07
Kaditcher6-May-06 1:07 
AnswerRe: Copy Objects - Am I missing something? Pin
Joshua Quick6-May-06 9:39
Joshua Quick6-May-06 9:39 
GeneralRe: Copy Objects - Am I missing something? Pin
Kaditcher9-May-06 7:24
Kaditcher9-May-06 7:24 
GeneralRe: Copy Objects - Am I missing something? Pin
Joshua Quick9-May-06 17:14
Joshua Quick9-May-06 17:14 
Questionselecting control at runtime (VB.NET) Pin
A M SOMAN6-May-06 0:55
A M SOMAN6-May-06 0:55 
QuestionPrinter Object in VB Pin
cberam6-May-06 0:01
cberam6-May-06 0:01 
AnswerRe: Printer Object in VB Pin
Duncan Edwards Jones8-May-06 3:23
professionalDuncan Edwards Jones8-May-06 3:23 
QuestionDSN File Change at run time Pin
prashantvashisht5-May-06 23:22
prashantvashisht5-May-06 23:22 
QuestionDisable Guest Account in VB Pin
QuickDeveloper5-May-06 23:07
QuickDeveloper5-May-06 23:07 
QuestionDatagrid Pin
militiaware5-May-06 21:33
militiaware5-May-06 21:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.