Talk About Network

Google





Software > Biz Talk Orchestration > Re: Accessing e...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 12 Topic 4205 of 4234
Post > Topic >>

Re: Accessing external Assembly

by Hashname <praseeth@[EMAIL PROTECTED] > Oct 22, 2008 at 11:27 AM

On Oct 22, 9:58=A0am, Aldebaran <Aldeba...@[EMAIL PROTECTED]
>
wrote:
> I tried 2 ways:
>
> 1.
> Public Function GetAxTarget(ByVal CustomerID As String) As String
> =A0 =A0 =A0 =A0 =A0 =A0 Dim strSQL As String
> =A0 =A0 =A0 =A0 =A0 =A0 Dim connStr As String
> =A0 =A0 =A0 =A0 =A0 =A0 connStr =3D "Data Source=3D(local);Initial
Catalo=
g=3Dxxx;User
> Id=3Dxxx;Password=3Dxxx;"
> =A0 =A0 =A0 =A0 =A0 =A0 Dim cn As New SqlConnection(connStr)
> =A0 =A0 =A0 =A0 =A0 =A0 Dim cmd As New SqlCommand("GetAxaptaTarget", cn)
> =A0 =A0 =A0 =A0 =A0 =A0 cn.Open()
>
> =A0 =A0 =A0 =A0 =A0 =A0 Try
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cmd.Parameters.Add("@[EMAIL PROTECTED]
",
SqlDbTy=
pe.NVarChar).Value
> =3D CustomerID
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cmd.CommandType =3D
CommandType.StoredPro=
cedure
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Dim adapter As SqlDataAdapter =3D New
Sql=
DataAdapter(cmd)
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Dim dt As DataTable =3D New DataTable
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 adapter.Fill(dt)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetAxTarget =3D
dt.Rows(0).Item(0).ToStri=
ng
> =A0 =A0 =A0 =A0 =A0 =A0 Catch ex As Exception
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Throw ex
> =A0 =A0 =A0 =A0 =A0 =A0 Finally
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cn.Close()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cn.Dispose()
> =A0 =A0 =A0 =A0 =A0 =A0 End Try
> End Function
>
> and
>
> 2.
>
> Public Function GetAxTarget(ByVal CustomerID As String) As String
> =A0 =A0 =A0 =A0 =A0 =A0 Dim strSQL As String
> =A0 =A0 =A0 =A0 =A0 =A0 Dim connStr As String
> =A0 =A0 =A0 =A0 =A0 =A0 If Me.cSqlConnection.State =3D
ConnectionState.Op=
en Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.cSqlConnection.Close()
> =A0 =A0 =A0 =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 =A0 =A0 =A0 Dim mSQLCommand As New
System.Data.SqlClient.SqlC=
ommand
> =A0 =A0 =A0 =A0 =A0 =A0 mSQLCommand.CommandText =3D "GetAxaptaTarget"
> =A0 =A0 =A0 =A0 =A0 =A0 mSQLCommand.CommandType =3D
CommandType.StoredPro=
cedure
> =A0 =A0 =A0 =A0 =A0 =A0 mSQLCommand.CommandTimeout =3D
Me.cExecutionTimeo=
ut
> =A0 =A0 =A0 =A0 =A0 =A0 mSQLCommand.Connection =3D Me.cSqlConnection
>
> =A0 =A0 =A0 =A0 =A0 =A0 Dim mSQLParameter_CustomerID As New
> System.Data.SqlClient.SqlParameter("@[EMAIL PROTECTED]
", SqlDbType.NVarChar)
> =A0 =A0 =A0 =A0 =A0 =A0 mSQLParameter_CustomerID.Value =3D CustomerID
> =A0 =A0 =A0 =A0 =A0 =A0
mSQLCommand.Parameters.Add(mSQLParameter_Customer=
ID)
>
> =A0 =A0 =A0 =A0 =A0 =A0 Dim mSQLDataAdapter As New
> System.Data.SqlClient.SqlDataAdapter(mSQLCommand)
> =A0 =A0 =A0 =A0 =A0 =A0 Dim mDataTable As New System.Data.DataTable
>
> =A0 =A0 =A0 =A0 =A0 =A0 Me.cSqlConnection.Open()
> =A0 =A0 =A0 =A0 =A0 =A0 mSQLDataAdapter.Fill(mDataTable)
> =A0 =A0 =A0 =A0 =A0 =A0 Me.cSqlConnection.Close()
>
> =A0 =A0 =A0 =A0 =A0 =A0 GetAxTarget =3D
mDataTable.Rows(0).Item(0).ToStri=
ng
> End Function
>
> Both I got the mentioned error message.
>
> "Hashname" wrote:
> > On Oct 22, 7:49 am, Aldebaran <Aldeba...@[EMAIL PROTECTED]
>
> > wrote:
> > > Hi everybody,
>
> > > I try to access a database using an external assembly (Serializable)
=
within
> > > an orchestration.
> > > First I describe the Assembly function I call
> > > The function I call access a stored Procedure. This procedure got as
> > > parameter the customerID and as result I get the axapta Address for
t=
his
> > > specific customer.
>
> > > That I had tested with a small win app which give me the expected
res=
ult.
>
> > > In the Orchestration I got an expression shape within an atomic
scope=
..
>
> > > Source:
> > > AxaptaDel =3D AxaptaDelivery;
>
> > > chk_nodes =3D AxaptaDel.SelectNodes("/*[local-name()=3D'purchorder'
a=
nd
> > > namespace-uri()=3D'']/*[local-name()=3D'header' and
> > > namespace-uri()=3D'']/*[local-name()=3D'extaccount' and
namespace-uri=
()=3D'']");
> > > chk_node =3D chk_nodes.Item(0);
>
> > > customer =3D chk_node.InnerText;
> > > System.Diagnostics.EventLog.WriteEntry("BTS Axapta Del - Set
target",
> > > customer);
>
> > > helper =3D new HelperClass();
> > > AxAdress =3D helper.GetAxTarget(customer);
> > > helper.Dispose();
> > > helper =3D null;
> > > AxaptaWS(Microsoft.XLANGs.BaseTypes.Address) =3D AxAdress;
>
> > > First I extract the customerID from the message and then I call the
f=
unction
> > > and set the result as Target for a dynamic ****t.
>
> > > Deployment works fine (no errors).
>
> > > So when I Receive a message I get everytime the following error
messa=
ge:
>
> > > Inner exception: Type 'System.Data.SqlClient.SqlConnection' in
Assemb=
ly
> > > 'System.Data, Version=3D2.0.0.0, Culture=3Dneutral,
> > > PublicKeyToken=3Db77a5c561934e089' is not marked as serializable.
>
> > > Does anbody can help me there???
>
> > > Thanks
>
> > > Marcus
>
> > Have you declared the SqlConnection as a member variable in
> > HelperClass?
> > If so move it to function GetAxTarget and keep it as a local variable.

I'm not sure what exactly is causing this issue in your case. I do
have few suggestions for you:
1) Check if you have declared SqlConnection Object anywhere in your
orchestration.
2) Try converting the "GetAxTarget" to a static method( shared in
vb.net) . This way you don't have to create an instance of
HelperClass(i.e, helper =3D new  HelperClass()) just to read a value
from Db.Also if you can, use ExecuteScalar to retrieve the value from
Db.Using DataAdapter to read a single value from Db seems a bit
overkill.
 




 12 Posts in Topic:
Accessing external Assembly
=?Utf-8?B?QWxkZWJhcmFu?=   2008-10-22 04:49:00 
Re: Accessing external Assembly
Hashname <praseeth@[EM  2008-10-22 06:22:24 
Re: Accessing external Assembly
=?Utf-8?B?QWxkZWJhcmFu?=   2008-10-22 06:58:09 
Re: Accessing external Assembly
Hashname <praseeth@[EM  2008-10-22 11:27:53 
Re: Accessing external Assembly
=?Utf-8?B?QWxkZWJhcmFu?=   2008-10-23 07:41:01 
Re: Accessing external Assembly
Andreas <andreas@[EMAI  2008-10-24 06:20:26 
Re: Accessing external Assembly
=?Utf-8?B?QWxkZWJhcmFu?=   2008-10-24 02:21:02 
Re: Accessing external Assembly
Andreas <andreas@[EMAI  2008-10-24 10:49:45 
Re: Accessing external Assembly
=?Utf-8?B?QWxkZWJhcmFu?=   2008-10-27 05:27:01 
Re: Accessing external Assembly
Dan Rosanova <dnova7@[  2008-10-24 08:29:23 
Re: Accessing external Assembly
"Eric Stott" &l  2008-10-23 12:17:54 
Re: Accessing external Assembly
=?Utf-8?B?QWxkZWJhcmFu?=   2008-10-24 02:28:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 18:08:34 PST 2009.