Home > Archive > SQL Anywhere Mobile > June 2005 > Connection_Script Problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Connection_Script Problem
madhu

2005-06-23, 8:24 pm

ML 9.0.2.3044
Windows Mobile 2003 2nd ed 4.21.1088.14049
Ultralite


Connection Script Details
---------------------------
Event : authenticate_user
Scritp Language : .NET
Script : MLExample.AuthClass.DoAuthenticate


when I synchronize, this is the log on the mobilink server.
E : No valid constructor was found for type "MLExample.AuthClass".

Here is the constructor I have in my class ( which the documentation
specifies will be used )
public AuthClass( DBConnectionContext cc )

{

_conn = cc.GetConnection();

}

I checked my using statement and also made sure the
iAnywhere.MobiLink.Script.dll exists.
I can get the .net synchronization logic to work for upload and download as
shown in the custd mobilink sample application.
But if I want only the authenticate_user to work in connection script. It
fails with the above Error.
Any help would be appreciated.


TIA
Madhu



Greg Fenton

2005-06-24, 11:25 am

madhu wrote:
>
> when I synchronize, this is the log on the mobilink server.
> E : No valid constructor was found for type "MLExample.AuthClass".
>


Can you post the entire code for your class?
Can you also post the ml_add_connection_sc
ript() configuration statement
used to load this script?

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
madhu

2005-06-24, 11:25 am

Here is the code for my class which I got from Mobilink documents. The
following is the location in the SQL Anywhere Studio 9.0.2 help.

MobiLink Administrative Guide
Writing Synchronization Scripts in .NET
.NET Synchronization example.



I followed the example as given.


------------------------------------------------------------------
using System;
using iAnywhere.MobiLink.Script;

namespace MLExample
{
public class AuthClass
{
private DBConnection _conn;

public AuthClass( DBConnectionContext cc )
{
_conn = cc.GetConnection();
}

/// The DoAuthenticate method handles the 'authenticate_user'
/// event.
/// Note: This method does not handle password changes for
/// advanced authorization status codes.

public void DoAuthenticate(
ref int authStatus,
string user,
string pwd,
string newPwd )
{

DBCommand pwd_command = _conn.CreateCommand();
pwd_command.CommandText = "select pwd from user_pwd_table"
+ " where user_name = ? ";
pwd_command.Prepare(); // add a parameter for the user name
DBParameter user_param = new DBParameter();
user_param.DbType = SQLType.SQL_CHAR;
// we need to set the size for SQL_VARCHAR
user_param.Size = (uint)user.Length;
user_param.Value = user;
pwd_command.Parameters.Add( user_param ); // fetch the password for
this user.
DBRowReader rr = pwd_command.ExecuteReader();
object[] pwd_row = rr.NextRow();
if( pwd_row == null )
{
// user is unknown
authStatus = 4000;
}
else
{
if( ((string)pwd_row[0]) == pwd )
{
// password matched
authStatus = 1000;
}
else
{
// password did not match
authStatus = 4000;
}
}
pwd_command.Close();
rr.Close();
return;
}
}
}
-----------------------------------------------------------------


call ml_add_dnet_connecti
on_script( 'Pocket_PC10', 'authenticate_user',

'MLExample.AuthClass.DoAuthenticate' )
COMMIT.

It would be really helpful to find out why I need a default constructor when
I synchronize.


Thanks for the reply.
Madhu






"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42bc215a$1@foru
ms-2-dub...
> madhu wrote:
>
> Can you post the entire code for your class?
> Can you also post the ml_add_connection_sc
ript() configuration statement
> used to load this script?
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/



madhu

2005-06-24, 8:24 pm

Also here is the help documentation about the contstructor I read.

public interface DBConnectionContext
Member of iAnywhere.MobiLink.Script
Interface for obtaining and accessing information about the current database connection. This is passed to the constructor of classes containing scripts. If context is required for a background thread or beyond the lifetime of a connection, use a ServerContext.

Caution:
A DBConnectionContext instance should not be used outside the thread that calls into your .NET code.


Interface for obtaining information about the current database connection. This is passed to the constructor of classes containing scripts.


-----------------------------------------------------------------------------------------------------
"madhu" <madhu. sangam@mobiledatafor
ce.com> wrote in message news:42bc33a5$1@foru
ms-2-dub...
> Here is the code for my class which I got from Mobilink documents. The
> following is the location in the SQL Anywhere Studio 9.0.2 help.
>
> MobiLink Administrative Guide
> Writing Synchronization Scripts in .NET
> .NET Synchronization example.
>
>
>
> I followed the example as given.
>
>
> ------------------------------------------------------------------
> using System;
> using iAnywhere.MobiLink.Script;
>
> namespace MLExample
> {
> public class AuthClass
> {
> private DBConnection _conn;
>
> public AuthClass( DBConnectionContext cc )
> {
> _conn = cc.GetConnection();
> }
>
> /// The DoAuthenticate method handles the 'authenticate_user'
> /// event.
> /// Note: This method does not handle password changes for
> /// advanced authorization status codes.
>
> public void DoAuthenticate(
> ref int authStatus,
> string user,
> string pwd,
> string newPwd )
> {
>
> DBCommand pwd_command = _conn.CreateCommand();
> pwd_command.CommandText = "select pwd from user_pwd_table"
> + " where user_name = ? ";
> pwd_command.Prepare(); // add a parameter for the user name
> DBParameter user_param = new DBParameter();
> user_param.DbType = SQLType.SQL_CHAR;
> // we need to set the size for SQL_VARCHAR
> user_param.Size = (uint)user.Length;
> user_param.Value = user;
> pwd_command.Parameters.Add( user_param ); // fetch the password for
> this user.
> DBRowReader rr = pwd_command.ExecuteReader();
> object[] pwd_row = rr.NextRow();
> if( pwd_row == null )
> {
> // user is unknown
> authStatus = 4000;
> }
> else
> {
> if( ((string)pwd_row[0]) == pwd )
> {
> // password matched
> authStatus = 1000;
> }
> else
> {
> // password did not match
> authStatus = 4000;
> }
> }
> pwd_command.Close();
> rr.Close();
> return;
> }
> }
> }
> -----------------------------------------------------------------
>
>
> call ml_add_dnet_connecti
on_script( 'Pocket_PC10', 'authenticate_user',

> 'MLExample.AuthClass.DoAuthenticate' )
> COMMIT.
>
> It would be really helpful to find out why I need a default constructor when
> I synchronize.
>
>
> Thanks for the reply.
> Madhu
>
>
>
>
>
>
> "Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
> news:42bc215a$1@foru
ms-2-dub...
>
>

madhu

2005-06-27, 1:24 pm

Is there anyone who came across this problem with authenticate_user connection script. It would be helpful if someone atleast says that it does not
work. I can look into other alternatives. It seems like I am writing to myself.

Thanks
Madhu


"madhu" <madhu. sangam@mobiledatafor
ce.com> wrote in message news:42bc6fbb@forums
-1-dub...
Also here is the help documentation about the contstructor I read.

public interface DBConnectionContext
Member of iAnywhere.MobiLink.Script
Interface for obtaining and accessing information about the current database connection. This is passed to the constructor of classes containing scripts. If context is required for a background thread or beyond the lifetime of a connection, use a ServerContext.

Caution:
A DBConnectionContext instance should not be used outside the thread that calls into your .NET code.


Interface for obtaining information about the current database connection. This is passed to the constructor of classes containing scripts.


-----------------------------------------------------------------------------------------------------
"madhu" <madhu. sangam@mobiledatafor
ce.com> wrote in message news:42bc33a5$1@foru
ms-2-dub...
> Here is the code for my class which I got from Mobilink documents. The
> following is the location in the SQL Anywhere Studio 9.0.2 help.
>
> MobiLink Administrative Guide
> Writing Synchronization Scripts in .NET
> .NET Synchronization example.
>
>
>
> I followed the example as given.
>
>
> ------------------------------------------------------------------
> using System;
> using iAnywhere.MobiLink.Script;
>
> namespace MLExample
> {
> public class AuthClass
> {
> private DBConnection _conn;
>
> public AuthClass( DBConnectionContext cc )
> {
> _conn = cc.GetConnection();
> }
>
> /// The DoAuthenticate method handles the 'authenticate_user'
> /// event.
> /// Note: This method does not handle password changes for
> /// advanced authorization status codes.
>
> public void DoAuthenticate(
> ref int authStatus,
> string user,
> string pwd,
> string newPwd )
> {
>
> DBCommand pwd_command = _conn.CreateCommand();
> pwd_command.CommandText = "select pwd from user_pwd_table"
> + " where user_name = ? ";
> pwd_command.Prepare(); // add a parameter for the user name
> DBParameter user_param = new DBParameter();
> user_param.DbType = SQLType.SQL_CHAR;
> // we need to set the size for SQL_VARCHAR
> user_param.Size = (uint)user.Length;
> user_param.Value = user;
> pwd_command.Parameters.Add( user_param ); // fetch the password for
> this user.
> DBRowReader rr = pwd_command.ExecuteReader();
> object[] pwd_row = rr.NextRow();
> if( pwd_row == null )
> {
> // user is unknown
> authStatus = 4000;
> }
> else
> {
> if( ((string)pwd_row[0]) == pwd )
> {
> // password matched
> authStatus = 1000;
> }
> else
> {
> // password did not match
> authStatus = 4000;
> }
> }
> pwd_command.Close();
> rr.Close();
> return;
> }
> }
> }
> -----------------------------------------------------------------
>
>
> call ml_add_dnet_connecti
on_script( 'Pocket_PC10', 'authenticate_user',

> 'MLExample.AuthClass.DoAuthenticate' )
> COMMIT.
>
> It would be really helpful to find out why I need a default constructor when
> I synchronize.
>
>
> Thanks for the reply.
> Madhu
>
>
>
>
>
>
> "Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
> news:42bc215a$1@foru
ms-2-dub...
>
>

Greg Fenton

2005-06-27, 1:24 pm

madhu wrote:
> Is there anyone who came across this problem with authenticate_user
> connection script. It would be helpful if someone atleast says that it
> does not work.


Since this is documented and there are examples (on which your code is
based), then it is supposed to work. This is such a simple thing you
are doing that I have to believe that it does work and you are running
into some configuration problem (.NET versions or whatever).

I understand that you are working with Technical Support on this issue.
Please post back once you have a solution to this problem. Others
might post here too, but since this issue has been ongoing it is getting
less likely that others in the ML community have run into this problem
or used the particular features you are trying.

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
madhu

2005-06-27, 8:24 pm

Thought this might be helpful.

Microsoft Development Environment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322 SP1

Thanks for the Reply.
Madhu



"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42c03f4a@forums
-1-dub...
> madhu wrote:
>
> Since this is documented and there are examples (on which your code is
> based), then it is supposed to work. This is such a simple thing you
> are doing that I have to believe that it does work and you are running
> into some configuration problem (.NET versions or whatever).
>
> I understand that you are working with Technical Support on this issue.
> Please post back once you have a solution to this problem. Others
> might post here too, but since this issue has been ongoing it is getting
> less likely that others in the ML community have run into this problem
> or used the particular features you are trying.
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/



madhu

2005-06-28, 8:25 pm

Finally got the thing resolved. Thanks for the help from the Technical Guys
at iAnywhere and also the forum.

Here is the info for someone who might run into this.

Just make sure that your assemblies in Global assembly Cache are up to date.
I had some old references from my sybase builds lying around.

Madhu


Jeff Albion \(iAnywhere Solutions\)

2005-06-29, 9:24 am

And for those that don't know, "Global Assemblies" are located in your
"%windir%\Assembly" folder. Be sure to view this folder in Explorer as it is
a specially viewed system folder.

--
Jeff Albion
Product Support Analyst
iAnywhere Solutions

"madhu" <madhu. sangam@mobiledatafor
ce.com> wrote in message
news:42c1c82f$1@foru
ms-2-dub...
> Finally got the thing resolved. Thanks for the help from the Technical

Guys
> at iAnywhere and also the forum.
>
> Here is the info for someone who might run into this.
>
> Just make sure that your assemblies in Global assembly Cache are up to

date.
> I had some old references from my sybase builds lying around.
>
> Madhu
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com