MySQL Primary Key returning Null value in Row_Inserted event

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
mpopkin
User
Posts: 9

MySQL Primary Key returning Null value in Row_Inserted event

Post by mpopkin »

Hello,

I'm attempting to use the Row_Inserted event to run an update query on a detail table based on the primary key value of the newly created record in the master table. It's an auto-increment column in a MySQL database.

The problem is, the key value is coming back as dbnull in this event. I'm using rs("ProviderID"). I opened the site up in Visual Studio to debug and I am able to get values for other columns, but not for the key column.

Has anybody seen this before? Do I need to do something special for MySQL to get the auto-increment value back at this spot?

Thanks, in advance!

Full event code:

' Row Inserted event
Public Sub Row_Inserted(rs As OrderedDictionary)
'HttpContext.Current.Response.Write("Row Inserted")

Dim txtSQL As new System.Text.StringBuilder
txtSQL.Append("INSERT INTO ProviderToInsurance " & vbCrLf)
txtSQL.Append("(ProviderID,InsuranceID,Notes) " & vbCrLf)
txtSQL.Append("(SELECT Provider.ProviderID, Insurance.InsuranceID,'system added - needs credentialing' AS Notes " & vbCrLf)
txtSQL.Append("FROM Insurance, Provider " & vbCrLf)
txtSQL.Append("WHERE Insurance.FKPayerID IN ( " & vbCrLf)
txtSQL.Append("SELECT EDI_Enrollment.FKpayerID " & vbCrLf)
txtSQL.Append("FROM EDI_Enrollment " & vbCrLf)
txtSQL.Append("WHERE EDI_Enrollment.PracticeID=Provider.PracticeID) AND ( " & vbCrLf)
txtSQL.Append("SELECT PI.ProviderID " & vbCrLf)
txtSQL.Append("FROM ProviderToInsurance PI " & vbCrLf)
txtSQL.Append("WHERE PI.ProviderID=Provider.ProviderID AND PI.InsuranceID=Insurance.InsuranceID) IS NULL) AND " & vbCrLf)
txtSQL.Append("Provider.ProviderID = '" & rs("ProviderID") & "';")

ew_Execute(txtSQL.ToString)

End Sub


vincenthung
User
Posts: 88

Post by vincenthung »

What version of ASP.NET Maker are you using?

Row_Inserted server event should have 2 parameters rsold and rsnew.

You can refer to the "ProviderID" with rsnew["ProviderID"].


Post Reply