Ed
asked on
Operator '=' is not defined for type 'Integer' and type 'DBNull'
The below code works until objComp3 has rows in it.
Then I get the error
Operator '=' is not defined for type 'Integer' and type 'DBNull'.
Then I get the error
Operator '=' is not defined for type 'Integer' and type 'DBNull'.
While objComp3.Read()
If objComp3("IVRECORDID") = DBNull.Value Then
Session("IQAComplianceMode") = "Update"
btnComplianceButton.Text = "Update Complance"
Else
Session("IQAComplianceMode") = "Insert"
btnComplianceButton.Text = "Add Complance"
End If
End While
Which line raises the error?
If objComp3("IVRECORDID") == DBNull.Value Then
a single = is an assignment, you need == to compare
a single = is an assignment, you need == to compare
Hi edjones1;
Try it like this.
Try it like this.
If objComp3("IVRECORDID") Is DBNull.Value Then
If objComp3 is a SqlDataReader, use this:
objComp3.IsDBNull(objComp3 .GetOrdina l("IVRECOR DID"))
objComp3.IsDBNull(objComp3
Ahh, wrong language!!
While objComp3.Read()
If objComp3("IVRECORDID") Is Nothing AndAlso objComp3("IVRECORDID") = DBNull.Value Then
Session("IQAComplianceMode") = "Update"
btnComplianceButton.Text = "Update Complance"
Else
Session("IQAComplianceMode") = "Insert"
btnComplianceButton.Text = "Add Complance"
End If
End While
ASKER
Sorry I made somwe errors in what I posted.
Here's the code that does not work.
I just want it to do one thing if the recordset has rows and something else if it does not.
Here's the code that does not work.
I just want it to do one thing if the recordset has rows and something else if it does not.
While objComp3.Read()
If objComp3("IVRECORDID") = DBNull.Value Then
Session("IQAComplianceMode") = "Insert"
btnComplianceButton.Text = "Add Complance"
lbIVIDCompliance.Text = "There is currently no compliance record stored for IV ID - " + ivid.ToString
lbIVIDCompliance.ForeColor = Color.DarkRed
Else
Session("IQAComplianceMode") = "Update"
btnComplianceButton.Text = "Update Complance"
lbIVIDCompliance.Text = "Update IV ID - " + ivid.ToString
End If
End While
ASKER
if objComp3 is empty I want to set the session to Insert
If objComp3 in not empty then set the Session to Update
If objComp3 in not empty then set the Session to Update
Hi,
try this code
try this code
While objComp3.Read()
If objComp3("IVRECORDID") IsNot Nothing AndAlso objComp3("IVRECORDID") <> DBNull.Value Then
Session("IQAComplianceMode") = "Update"
btnComplianceButton.Text = "Update Complance"
Else
Session("IQAComplianceMode") = "Insert"
btnComplianceButton.Text = "Add Complance"
End If
End While
ASKER
Lokesh B R
I have tried the code but nothing happens
btnComplianceButton.Text and Session("IQAComplianceMode ") is blank
I have tried the code but nothing happens
btnComplianceButton.Text and Session("IQAComplianceMode
Does this work?
One problem I can see is that you are setting same session variable and same button text in a loop. Are you only expecting one row in the reader?
One problem I can see is that you are setting same session variable and same button text in a loop. Are you only expecting one row in the reader?
While objComp3.Read()
If IsDBNull(objComp3("IVRECORDID")) Then
Session("IQAComplianceMode") = "Insert"
btnComplianceButton.Text = "Add Complance"
lbIVIDCompliance.Text = "There is currently no compliance record stored for IV ID - " + ivid.ToString
lbIVIDCompliance.ForeColor = Color.DarkRed
Else
Session("IQAComplianceMode") = "Update"
btnComplianceButton.Text = "Update Complance"
lbIVIDCompliance.Text = "Update IV ID - " + ivid.ToString
End If
End While
ASKER
CodeCruiser
I'm afraid that it does not work..
lbIVIDCompliance.Text remains blank and the session gets set to neither INSERT OR UPDATE..
The dataset gets populated by this..
I'm afraid that it does not work..
lbIVIDCompliance.Text remains blank and the session gets set to neither INSERT OR UPDATE..
The dataset gets populated by this..
ALTER PROCEDURE [dbo].[GET_IQA_Compliance]
@IVRecordID int
AS
Select
[TRAINEEID]
,[POT]
,[ADDEDBY]
,[IVRECORDID]
,[CREDITSCORRECT]
,[RULESCOMBINATIONCORRECT]
,[ILPINPLACE]
,[ILPUPTODATE]
,[HAVEPREVIOUSACTIONSCOMPLETED]
,[ISDELIVERYMODELINPLACE]
,[ISDELIVERYMODELUPTODATE]
From
[dbo].[I_IQA_COMPLIANCE]
where IVRECORDID = @IVRecordID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It was not getting the ID from
GridIVRecs.SelectedDataKey .Value
GridIVRecs.SelectedDataKey