Hi There,
I have a web service (its very simple). In the same solution I have a C# (class) and VB (form). I am using the VB form to check the c# class.
Now. I have a web service that expose a c# method. following is the web service code.
DBHandle.HandleDB PeerInfo;
private int IsPeerValid = 0;
[WebMethod]
public int IsAValidPeer(int intPeerID)
{
PeerInfo = new DBHandle.HandleDB();
int intLocalPeerID = intPeerID;
bool boolPeerStatus= false;
boolPeerStatus = PeerInfo.IsValidPeer(intLocalPeerID);
if (boolPeerStatus)
{
IsPeerValid = 1;
}
return IsPeerValid;
}
the code for IsValidPeer method is:
public bool IsValidPeer(int intPeerID)
{
String dbPeerValidProcedure;
int intProcedureReturn;
bool isValid = false;
bool openDB;
openDB = OpenDatabase();
//Database should now be opended
if (openDB == false)
{
Console.WriteLine("Can not open Database");
}
else
{
dbPeerValidProcedure = "CheckPeerID"; //Name of the stored procedure
dbCommand = new System.Data.SqlClient.SqlCommand(dbPeerValidProcedure, dbConnection);
dbCommand.CommandType = System.Data.CommandType.StoredProcedure;
dbParameter = dbCommand.Parameters.Add("@P_ID", System.Data.DbType.Int32);
dbParameter.Direction = System.Data.ParameterDirection.Input;
dbCommand.Parameters["@P_ID"].Value = intPeerID;
try
{
intProcedureReturn = (int) dbCommand.ExecuteScalar();
isValid = true;
Console.WriteLine(intProcedureReturn);
}
catch(System.Exception StoredProcedureException)
{
Console.WriteLine("Stored procedure exception" + StoredProcedureException.ToString());
}
}
if (!CloseDatabase())
{
Console.WriteLine("could not close Database");
}
return isValid;
}
My question is:
(1) When I tested the method from VB form the correct int value is returned (1), but when I share the method over the Web Service I dont get the correct value. I get 0. I can not see why this happens..Any ideas?
Thanks in advance.
Mal.
I have a web service (its very simple). In the same solution I have a C# (class) and VB (form). I am using the VB form to check the c# class.
Now. I have a web service that expose a c# method. following is the web service code.
DBHandle.HandleDB PeerInfo;
private int IsPeerValid = 0;
[WebMethod]
public int IsAValidPeer(int intPeerID)
{
PeerInfo = new DBHandle.HandleDB();
int intLocalPeerID = intPeerID;
bool boolPeerStatus= false;
boolPeerStatus = PeerInfo.IsValidPeer(intLocalPeerID);
if (boolPeerStatus)
{
IsPeerValid = 1;
}
return IsPeerValid;
}
the code for IsValidPeer method is:
public bool IsValidPeer(int intPeerID)
{
String dbPeerValidProcedure;
int intProcedureReturn;
bool isValid = false;
bool openDB;
openDB = OpenDatabase();
//Database should now be opended
if (openDB == false)
{
Console.WriteLine("Can not open Database");
}
else
{
dbPeerValidProcedure = "CheckPeerID"; //Name of the stored procedure
dbCommand = new System.Data.SqlClient.SqlCommand(dbPeerValidProcedure, dbConnection);
dbCommand.CommandType = System.Data.CommandType.StoredProcedure;
dbParameter = dbCommand.Parameters.Add("@P_ID", System.Data.DbType.Int32);
dbParameter.Direction = System.Data.ParameterDirection.Input;
dbCommand.Parameters["@P_ID"].Value = intPeerID;
try
{
intProcedureReturn = (int) dbCommand.ExecuteScalar();
isValid = true;
Console.WriteLine(intProcedureReturn);
}
catch(System.Exception StoredProcedureException)
{
Console.WriteLine("Stored procedure exception" + StoredProcedureException.ToString());
}
}
if (!CloseDatabase())
{
Console.WriteLine("could not close Database");
}
return isValid;
}
My question is:
(1) When I tested the method from VB form the correct int value is returned (1), but when I share the method over the Web Service I dont get the correct value. I get 0. I can not see why this happens..Any ideas?
Thanks in advance.
Mal.