关于组件开发的问题!高手来帮忙!给我个建议!谢谢!顺便看看你的实力!急急急!

nmgwolf 2006-12-27 11:00:06
[assembly: ApplicationName("TransactionServer")]
[assembly:ApplicationActivation(ActivationOption.Server)]
[assembly:ApplicationAccessControl(Value=false ,Authentication=AuthenticationOption.None)]

namespace transerver1
{
public interface trans
{
void AddTran(string loginid, string password);
}
[InterfaceQueuing (Interface ="trans")]
public class TransCls:ServicedComponent,trans
{
public SqlConnection sqlConnection;
public SqlCommand updateCommand, insertCommand, selectCommand;
public SqlTransaction SqlTrans;
public SqlDataReader readval;


public void AddTran(string loginid, string password)
{
string retval = null;
sqlConnection = new SqlConnection("Server=localhost;database=Jessups;user id=sa;password=");
sqlConnection.Open();
SqlTrans = sqlConnection.BeginTransaction();
insertCommand = new SqlCommand();
updateCommand = new SqlCommand();
selectCommand = new SqlCommand();
insertCommand.Connection = sqlConnection;

try
{
selectCommand = new SqlCommand("select count(*) from admin where login='" + loginid + "' and password='" + password + "'", sqlConnection);
selectCommand.Transaction = SqlTrans;
int count = Convert.ToInt32(selectCommand.ExecuteScalar());
if (count > 0)
{
retval += "委托成功!";
}
else
{
SqlTrans.Rollback();
retval += "登陆失败!";
}
}
catch (Exception e)
{
retval += "Error generated while doing transaction\n" + e.Message.ToString();
SqlTrans.Rollback();
retval += "登陆失败!事物回滚!";
}

sqlConnection.Close();
//return retval;//returning the status to the Client
}
}
}
以上是COM+组件代码!
我编写远程对象代码,应该怎么写?帮忙千万!一共需要TCP服务器,客户端,COM+组件,远程调用.这个远程对象调用该怎么写啊?
...全文
51 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,552

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧