|
-
Apr 12th, 2004, 08:46 PM
#1
Thread Starter
New Member
Validating for empty datafields
Hi I got a problem whereby my boss has failed to maintain the AS400 server's database. This means that I will have field "elrsnc" being empty and causing major problem to my work.
Elrsnc is suppose to represent a value of 1-11. So base on the selected value i will insert a strFieldName (example value 1, strFieldname ="XRSN01") into another table empexit. My problem is if Im running my codes as of those below, how should I validate for rsCode.Fields("elrsnc") = ""
sql2 = "select empno, edcode, elyyyy, elmm, eldd, elrsnc from EMPloyee " & _
"where empno = '" & empno & "'"
rsCode.Open sql2, cn, adOpenKeyset, adLockOptimistic
intELRSNC = CInt(rsCode.Fields("elrsnc"))
Select Case intELRSNC
Case 1: strFieldName = "XRSN01"
Case 2: strFieldName = "XRSN02"
Case 3: strFieldName = "XRSN03"
Case 4: strFieldName = "XRSN04"
Case 5: strFieldName = "XRSN05"
Case 6: strFieldName = "XRSN06"
Case 7: strFieldName = "XRSN07"
Case 8: strFieldName = "XRSN08"
Case 9: strFieldName = "XRSN09"
Case 10: strFieldName = "XRSN10"
Case 11: strFieldName = "XRSN11"
End Select
-
Apr 12th, 2004, 09:02 PM
#2
I'm not sure what you are asking. Do you mean how do you check if the field is empty?
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 12th, 2004, 09:21 PM
#3
Thread Starter
New Member
Yup how do i check when field "elrsnc" is empty? If its empty i need to insert strFieldName = "" into the database table else i need to run my select case. Do you get what i mean? Thanks
-
Apr 12th, 2004, 09:26 PM
#4
Thread Starter
New Member
My elrsnc will potentially be empty. Then when I try to CInt it
will return me an error
-
Apr 12th, 2004, 09:29 PM
#5
You just need to add some error handling then.
Or, maybe not the best, but:
VB Code:
On Error Goto Err:
intELRSNC = CInt(rsCode.Fields("elrsnc"))
Select Case intELRSNC
Case 1: strFieldName = "XRSN01"
Case 2: strFieldName = "XRSN02"
Case 3: strFieldName = "XRSN03"
Case 4: strFieldName = "XRSN04"
Case 5: strFieldName = "XRSN05"
Case 6: strFieldName = "XRSN06"
Case 7: strFieldName = "XRSN07"
Case 8: strFieldName = "XRSN08"
Case 9: strFieldName = "XRSN09"
Case 10: strFieldName = "XRSN10"
Case 11: strFieldName = "XRSN11"
End Select
Exit Sub 'or function if its a function
Err:
Does the same really...
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 12th, 2004, 09:51 PM
#6
Thread Starter
New Member
If Im going to insert the strFieldName as below.
sql3 = "insert into empexit(XEMPNO,xdcode,xlyyyy, xlmm, xldd, " & strFieldName & "
Is this way of error handling correct?
On Error Goto Err:
intELRSNC = CInt(rsCode.Fields("elrsnc"))
Select Case intELRSNC
Case 1: strFieldName = "XRSN01"
Case 2: strFieldName = "XRSN02"
Case 3: strFieldName = "XRSN03"
Case 4: strFieldName = "XRSN04"
Case 5: strFieldName = "XRSN05"
Case 6: strFieldName = "XRSN06"
Case 7: strFieldName = "XRSN07"
Case 8: strFieldName = "XRSN08"
Case 9: strFieldName = "XRSN09"
Case 10: strFieldName = "XRSN10"
Case 11: strFieldName = "XRSN11"
End Select
Exit Sub
Err:
strFieldName = ""
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|