Smartdevice VB App calling C# Library Failed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Solution File containing 2 SmartDevices Projec
One is Smartdevice Application (VB), another was Smartdevice Class (C#
The Program failed on conn.open() inside class method loginServer() in the C# code belo

The source for class is as below, these version is modified by my previous .NET Framework class
using System
using System.Data.SqlClient
using System.Collections

namespace COR


public class clsSE

/// <summary
/// Summary description for clsMLM
/// </summary
public string g_ConnectionStr = ""
public string g_ErrMsg = ""

public clsSEM(

g_ConnectionStr = "Persist Security Info=False;User ID=mlsdba;Password=notellingu;Initial Catalog=mls;Data Source=localhost";


public string loginServer(string i_userID, string i_pwd

string p_sql = "EXEC sp_login '" + i_userID + "', '" + i_pwd + "'";
string intReturnValue = ""

SqlConnection conn = new SqlConnection(g_ConnectionStr)
SqlCommand cmd = new SqlCommand(p_sql, conn);
tr

conn.Open()
SqlDataReader rs = cmd.ExecuteReader()
if ( rs.Read() == true

intReturnValue = rs["login_status"].ToString();

rs.Close()

catch(Exception e

// g_ErrMsg = "[" + e.Source + "]" + e.Message
g_ErrMsg = e.Message


finall

conn.Close()

return intReturnValue



public string changePassword(string i_studentID, string i_studentOldPassword, string i_studentNewPassword

string p_sql = "EXEC sp_changepassword '" + i_studentID + "', '"
+ i_studentOldPassword + "', '"
+ i_studentNewPassword + "'"

string sReturnValue = ""

SqlConnection conn = new SqlConnection(g_ConnectionStr)
SqlCommand cmd = new SqlCommand(p_sql, conn)
SqlDataReader rs = null
tr

conn.Open()
rs = cmd.ExecuteReader()
if ( rs.Read() == true

sReturnValue = rs["return_status"].ToString();

rs.Close()

catch(Exception e

// g_ErrMsg = "[" + e.Source + "]" + e.Message
g_ErrMsg = e.Message

finall

conn.Close()

return sReturnValue



public string removeStudent(string i_studentID

return null





--------------------------------------------------------------------------
My Smartdevice contains of 3 textbox and a butto
below is the button click event's cod

Dim o_login As New CORE.clsSE
TextBox3.Text = o_login.loginServer(Trim(TextBox1.Text), Trim(TextBox2.Text)

--------------------------------------------------------------------------
I've write both VB.NET Windows Application and Web Application to test this class. but now I try to port it into
PocketPC.

Please help..

Thanks
Ron
 
hi ronwho,

have you compiled the assembly against the compact framework?

the same physical assembly you compiled for use in your vb.net w32 and web
apps will not be accessible from any compact framework targeted applications
as elements that are potentially compiled into this assembly may not be
supported by the compact framework. you'll need to copy (or share thorugh
sourcesafe) your physical class file into another directory and create a new
smart device application (class library) which will then be compiled against
the compact framework. once this is done, you can then reference the new
assembly from your smart device applications.

when you create the new project be sure to use conditional compilation to
exclude any code that may utilize full framework functionality that is not
supported by the compact framework.

hope this helps,

jim

ronwho said:
I have a Solution File containing 2 SmartDevices Project
One is Smartdevice Application (VB), another was Smartdevice Class (C#)
The Program failed on conn.open() inside class method loginServer() in the C# code below

The source for class is as below, these version is modified by my previous ..NET Framework class.
using System;
using System.Data.SqlClient;
using System.Collections;

namespace CORE
{

public class clsSEM
{
/// <summary>
/// Summary description for clsMLM.
/// </summary>
public string g_ConnectionStr = "";
public string g_ErrMsg = "";

public clsSEM()
{
g_ConnectionStr = "Persist Security Info=False;User
ID=mlsdba;Password=notellingu;Initial Catalog=mls;Data Source=localhost";
}


public string loginServer(string i_userID, string i_pwd)
{
string p_sql = "EXEC sp_login '" + i_userID + "', '" + i_pwd + "'";
string intReturnValue = "";

SqlConnection conn = new SqlConnection(g_ConnectionStr);
SqlCommand cmd = new SqlCommand(p_sql, conn);
try
{
conn.Open();
SqlDataReader rs = cmd.ExecuteReader();
if ( rs.Read() == true)
{
intReturnValue = rs["login_status"].ToString();
}
rs.Close();
}
catch(Exception e)
{
// g_ErrMsg = "[" + e.Source + "]" + e.Message;
g_ErrMsg = e.Message;

}
finally
{
conn.Close();
}
return intReturnValue;
}

}
public string changePassword(string i_studentID, string
i_studentOldPassword, string i_studentNewPassword)
{
string p_sql = "EXEC sp_changepassword '" + i_studentID + "', '"
+ i_studentOldPassword + "', '"
+ i_studentNewPassword + "'";

string sReturnValue = "";

SqlConnection conn = new SqlConnection(g_ConnectionStr);
SqlCommand cmd = new SqlCommand(p_sql, conn);
SqlDataReader rs = null;
try
{
conn.Open();
rs = cmd.ExecuteReader();
if ( rs.Read() == true)
{
sReturnValue = rs["return_status"].ToString();
}
rs.Close();
}
catch(Exception e)
{
// g_ErrMsg = "[" + e.Source + "]" + e.Message;
g_ErrMsg = e.Message;
}
finally
{
conn.Close();
}
return sReturnValue;

}

public string removeStudent(string i_studentID)
{
return null;
}
}


}

-------------------------------------------------------------------------- -
My Smartdevice contains of 3 textbox and a button
below is the button click event's code

Dim o_login As New CORE.clsSEM
TextBox3.Text = o_login.loginServer(Trim(TextBox1.Text), Trim(TextBox2.Text))
--------------------------------------------------------------------------
-
I've write both VB.NET Windows Application and Web Application to test
this class. but now I try to port it into
 
yes, i have physically copy the .cs file to a the Smartdevice Class Application directory and compile again with no error
yes, i know that compact framework contains less namespace as .NET Framework
e.g. Exception doesn't has .Source only got .Message, that's why i change my g_ErrMsg = "[" + e.Source + "]" + e.Message; to g_ErrMsg = e.Message
 
Back
Top