DLL throwing error with specific function.

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

I believe you can change the timeout settings with a property in your connection string. Also, you probably don’t want to expose your login and password to your database. Be careful about blindly pasting your code.

Thanks Matt for you answer…

now my function is this…

Public Sub SendOrderMail()

Dim CON As New SqlConnection, CMD As New SqlCommand, DR As SqlDataReader

Dim QueryOrd As String, HTMLStr As String

QueryOrd = “select * from table where condition”

CON = New SqlConnection(“server=ServerName;uid=XXX;pwd=XXX;database=XXX;Connect Timeout=60”)

CON.Open()

CON.Close()

End Sub

it is having error at CON.open() function…and error is…


This message is for C/AL programmers:

The call to member sendOrderMail failed. mscorlib returned the following message:

Request for the permission of type ‘System.data.SqlCLient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ Failed.


anyone can help…?