|
-
Apr 16th, 2019, 03:16 AM
#1
Thread Starter
Member
[RESOLVED] Debugging fine on VS 17 but application crashing when executing the .exe
Hi, let me explain a bit my code purpose before to present my issue. 
I have a .net application which manage procedure forms.
When the form is not finish after 30 days, I want to notify the user that he need to check this one (A reminder). The notification is a mail notification send thanks to a SMTP Server, the sub procedure works well in others function and I think this is not the problem.
Here is my code :
VB.NET Code:
Function Notif_Rappel() As String()
Dim i%
Connexion.Open()
Dim Rq As String = "SELECT * FROM Donnees_MET WHERE Emet <> 'init'"
Dim Cmd As New SqlCommand(Rq, Connexion)
Dim Reader As SqlDataReader = Cmd.ExecuteReader()
Try
While Reader.Read()
'IF THE REQUEST IS OPEN SINCE MORE THAN 30 DAYS
If DateDiff(DateInterval.Day, Reader("Date_Demande"), Now) > 30 And Reader("Soldee") Is DBNull.Value Then
If Reader("Date_Last_Notif_RespMET") Is DBNull.Value Then GoTo 1
'IF A FIRST REMINDER HAS BEEN EXECUTED THEN CHECK THE 30 DAYS BETWEEN TODAY'S AND THE REMINDER'S DATES
If DateDiff(DateInterval.Day, Reader("Date_Last_Notif_RespMET"), Now) > 30 And Reader("Soldee") Is DBNull.Value Then
1: ReDim Preserve tab_notif(2, i)
tab_notif(0, i) = Reader("Num_MET")
tab_notif(1, i) = DateDiff(DateInterval.Day, Reader("Date_Demande"), Now)
tab_notif(2, i) = Reader("Resp_MET")
i = i + 1
End If
End If
End While
Catch ex As Exception
MsgBox(ex.Message & " Catégorie d'erreur N° 10")
Finally
Cmd.Dispose()
Connexion.Close()
End Try
End Function
Sub Write_Date_Notif()
'GET AN ARRAY WITH NUMBER, DATE, AND NAME
Notif_Rappel()
Dim Rq As String
For i = 0 To Int((tab_notif.Length - 1) / 3)
'FOR EACH ELEMENT IN ARRAY THEN SET DATE_Last_Notif WITH THE TODAY'S DATE AND SEND MAIL TO THE USER
Connexion.Open()
Rq = "UPDATE Donnees_MET SET Date_Last_Notif_RespMET ='" & Now.ToShortDateString() & "' WHERE Num_MET = '" & tab_notif(0, i) & "'"
Dim Cmd As New SqlCommand(Rq, Connexion)
Try
Cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message & " Catégorie d'erreur N° 10")
Finally
Cmd.Dispose()
Connexion.Close()
End Try
'SENDING MAILS
Dim sSubject$ = "Rappel, votre MET N° " & Mid(tab_notif(0, i), 1, 2) & "-" & Mid(tab_notif(0, i), 3, 3) & " est toujours en attente !"
Dim sBody$ = "Bonjour, <br /><br />La MET N° " & Mid(tab_notif(0, i), 1, 2) & "-" & Mid(tab_notif(0, i), 3, 3) & " attend une action de votre part depuis " & tab_notif(1, i) & " jours.<br />Ceci est un rappel.<br /><br />Cordialement."
Dim sTo(0) As String
sTo(0) = Mail_Nom(tab_notif(2, i))
Dim sCC(0) As String
sCC(0) = ""
Next
End Sub
Some comments :
-> First I use the function "Notif_Rappel" to get an array with the number of the procedure form, the name of the responsible and the Date of beginning when 30 days from beginning to taday have passed
-> Then, in "Write_Date_Notif" I stock in SQL the last date of notification (Today's date) and send a mail to the responsible of the procedure form.
The issue : 
This code works perfectly fine when I'm in Visual Studio (no debugging issue) nut when I publish it and launch the .exe, I get the following error :

Translation : An unhandled exception has occurred in your application. if you click continue, the application will ignore this wander and try to continue. If you click Quit, the application will stop immediately. Object reference not set to an instance of an object.
Do you have any explanation to that exception ? And how can I have exception with the .exe but nothing in the Visual Studio ? Thank you by advance, Mac.
Tags for this Thread
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
|