I am creating a program using modules and find there are issues in the SetParameters I am not understanding.
Program example extracts below:
From the Import.bas file I call a Sub in DM module.bas
In the DM.bas module I have the Public Sub (which works as shown)
However if I want to use a different name in the SetParameter It gives an error message. Below in the example I have changes the Parameter name in the sub to DbDate and the SetParameter to reflect that name (cmd.SetParameter("TheDbDate", DbDate), and so on
Code such as this:
WHY DOES THE ERROR SHOW UP From a Simple Variable change?
Program example extracts below:
From the Import.bas file I call a Sub in DM module.bas
B4X:
TheFile = "20091206"
TheDbDate = TheFile + 0
Msgbox("TheDbDate " & TheDbDate)
DM.WorkMeetDte(TheDbDate)
In the DM.bas module I have the Public Sub (which works as shown)
B4X:
Public Sub WorkMeetDte(TheDbDate)
' open MeetDte Table in Data Database
' check if this TheDbDate exists which says files have already been imported for this date.
' then check if this meeting 'RceCde' are in already or can be added
con.BeginTransaction
cmd.AddParameter("TheDbDate")
cmd.SetParameter("TheDbDate", TheDbDate)
cmd.CommandText = "SELECT * FROM MeetDte WHERE TheDbDate=@TheDbDate"
reader.Value = cmd.ExecuteReader
If reader.ReadNextRow = True Then
' must have found the row if a record is here
Msgbox("Exists MeetDte entry")
Else
' not new row so no record found
' add new record to MeetDte table
Msgbox("New MeetDte entry")
End If
reader.Close
con.EndTransaction
End Sub
However if I want to use a different name in the SetParameter It gives an error message. Below in the example I have changes the Parameter name in the sub to DbDate and the SetParameter to reflect that name (cmd.SetParameter("TheDbDate", DbDate), and so on
Code such as this:
B4X:
Public Sub WorkMeetDte(DbDate)
' open MeetDte Table in Data Database
' check if this TheDbDate exists which says files have already been imported for this date.
' then check if this meeting 'RceCde' are in already or can be added
con.BeginTransaction
cmd.AddParameter("TheDbDate")
cmd.SetParameter("TheDbDate", DbDate)
cmd.CommandText = "SELECT * FROM MeetDte WHERE TheDbDate=@DbDate"
reader.Value = cmd.ExecuteReader
If reader.ReadNextRow = True Then
' must have found the row if a record is here
Msgbox("Exists MeetDte entry")
Else
' not new row so no record found
' add new record to MeetDte table
Msgbox("New MeetDte entry")
End If
reader.Close
con.EndTransaction
End Sub
WHY DOES THE ERROR SHOW UP From a Simple Variable change?