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

nmgwolf nmgwolf 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
[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+组件,远程调用.这个远程对象调用该怎么写啊?
...全文
评论
收藏 已收藏
分享
返回顶部
nmgwolf
C# 111,129 成员 642,540 内容