Hello Frnds!
I have made a Dotnet DLL in VB.net. I have called it from Navision it worked fine…when I added one more function in DLL that connects to SQL server and get the data from Sales Header and Customer Table. Dll has started to throw the Error…but when I run that DLL from DotNet itself it is running fine…
SaleOrdermail is the function in DLL that throwing the error.
The error is :
This message is for C/AL programmers: The call to member SaleOrdermail failed. .Net SqlClient Data Provider returned the follwing message: Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding.
My Function is this:
Public Sub SaleOrderMail(ByVal SaleOrdNo As String, ByVal StrTo As String, ByVal StrCC As String, ByVal StrBCC As String, ByVal StrFrom As String, ByVal StrSubject As String)
Dim CON As New SqlConnection, CMD As New SqlCommand, DR As SqlDataReader
Dim QueryOrd, strHTML, StrUOM As String
QueryOrd = "SELECT SL.No_, CU.Name CustName, SL.Description ItemDes, CU.[E-Mail] Email, SL.[Unit of Measure] UOM, " + _
"SL.Quantity Qnt, SL.[Unit Price] Rate, " + _
"SL.[Promised Delivery Date] PDD FROM [AnsunDBase].[dbo].[Ansun Multitech Ind Ltd_$Sales Line] SL, " + _
"[AnsunDBase].[dbo].[Ansun Multitech Ind Ltd_$Customer] CU where " + _
“[Document No_] = '” + SaleOrdNo + "’ and SL.[Sell-to Customer No_] = CU.No_ "
CON = New SqlConnection(“server=192.168.0.100;uid=sa;pwd=navision;database=AnsunDbase”)
CON.Open()
CMD = New SqlCommand(QueryOrd, CON)
DR = CMD.ExecuteReader()
Dim Sno As Int32, TotQnt As Double, LineQnt As Double
Sno = 1
While (DR.Read())
If DR(“UOM”).ToString() = “KPCS” Then
StrUOM = “Rate (Rs/1000 Pcs)”
LineQnt = CDbl(DR(“Qnt”)) * 1000
ElseIf DR(“UOM”).ToString() = “Gross” Then
StrUOM = “Rate (Rs/1000 Pcs)”
LineQnt = CDbl(DR(“Qnt”)) * 144
Else
StrUOM = "Rate "
End If
strHTML = strHTML + " " + Sno.ToString() + " "
strHTML = strHTML + " " + DR(“ItemDes”).ToString() + " "
strHTML = strHTML + " " + DR(“UOM”).ToString() + " "
strHTML = strHTML + " " + LineQnt.ToString() + " "
strHTML = strHTML + " " + DR(“Rate”).ToString(“0.00”) + " "
strHTML = strHTML + " " + DR(“PDD”).ToString() + " "
Sno += 1 : TotQnt += LineQnt
End While
DR.Close()
CON.Close()
End Sub