从另一台机器访问智能客户端应用程序 [英] Access smart client application from another machine

查看:138
本文介绍了从另一台机器访问智能客户端应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行一个基于智能客户端的示例应用程序时,我遇到了一个问题.无论数据库如何,我都在同一台计算机上运行服务器和客户端,它工作正常.从其他计算机运行客户端时,出现以下错误,并且我在网络上搜索了很多解决方案,但是没有运气.

I am facing an issue while running one sample application which is smart client based. I am running server and client on the same machine irrespective of database, it''s working fine. While running the client from other machine, I am getting following error and I have searched a lot of solutions on net but there is no luck.

请求类型为System.Data.SqlClient.SqlClientPermission的许可,System.Data,Version = 2.0.0.0 ...."

"Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0...."

我已授予代码汇编"FullTrust"权限.

I have given "FullTrust" permission on code assembly.

这真的很可贵,如果能使您的早期响应.这是非常紧急的.

It will be really appreciable, if will get your early response. it is very urgent.

从其他计算机打开连接时显示错误.

Showing error while opening the connection from other machine.

使用System;
使用System.Data;
使用System.Data.SqlClient;
使用System.ComponentModel;
使用System.Configuration;
使用System.Security.Permissions;

///< summary>
///Class1的摘要描述
///</summary>
公共类Class1
{

    SqlClientPermission Permission =新的SqlClientPermission(PermissionState.Unrestricted);
    
   SqlCommand cmd; SqlDataReader博士; SqlDataAdapter da;
   //SqlConnection connect = null;
   公共布尔RecordExist(字符串sSql)
{

       //            
       //             if(connect.State = connect.Open() )
        //             {
       //                 connect.Close();
       //                 connect.Open();
       //            }
       //             else
       //             {
      字符串strCon = WinServer.Properties.Settings.Default.ToString();
//ConfigurationSettings.AppSettings["ConnectionString].ToString();
        SqlConnection connect =新的SqlConnection(strCon);
       connect.Open();
       //}

        cmd =新的SqlCommand(sSql);
       cmd.Connection = connect;
       cmd.ExecuteNonQuery();
       Dr = cmd.ExecuteReader();

                            如果(Dr.HasRows)
{
                     cmd.Connection.Close();//Ratnesh
                                  返回true;

       }
      其他
       {
                     cmd.Connection.Close();//Ratnesh
          返回false;

       }
       connect.Dispose();
       //connect.Close();

    }
    //================================================ ==========================


 
  公共System.Data.DataSet ReturnDataSet(字符串sql)
{
       Permission.Assert();    
      字符串strCon = WinServer.Properties.Settings.Default.ConnectionString.ToString();//ConfigurationSettings.AppSettings ["ConnectionString"].ToString();
SqlConnection connect =新的SqlConnection(strCon);
       connect.Open();
       //string strCon =数据源= .;初始目录= LUPS;用户ID = sa; pwd = sa";//ConfigurationSettings.AppSettings ["ConnectionString"].ToString();
        DataSet ds = new DataSet();
       da =新的SqlDataAdapter(sql,connect);
       da.Fill(ds,"r");
       connect.Close();
       connect.Dispose();
       return(ds);
    }

 using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Configuration;
using System.Security.Permissions;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{

    SqlClientPermission Permission = new SqlClientPermission(PermissionState.Unrestricted);
    
    SqlCommand cmd; SqlDataReader Dr; SqlDataAdapter da;
    //SqlConnection connect = null;
    public bool RecordExist(string sSql)
    {

        //            
        //            if ( connect.State=connect.Open()  )
        //            {
        //                connect.Close();
        //                connect.Open();
        //            }
        //            else
        //            {
        string strCon = WinServer.Properties.Settings.Default.ToString();
            //ConfigurationSettings.AppSettings["ConnectionString"].ToString();
        SqlConnection connect = new SqlConnection(strCon);
        connect.Open();
        //}

        cmd = new SqlCommand(sSql);
        cmd.Connection = connect;
        cmd.ExecuteNonQuery();
        Dr = cmd.ExecuteReader();

        if (Dr.HasRows)
        {
            cmd.Connection.Close();//Ratnesh
            return true;

        }
        else
        {
            cmd.Connection.Close();//Ratnesh
            return false;

        }
        connect.Dispose();
        //connect.Close();

    }
    //===========================================================================

    
    public System.Data.DataSet ReturnDataSet(string sql)
    {
        Permission.Assert();    
        string strCon = WinServer.Properties.Settings.Default.ConnectionString.ToString();// ConfigurationSettings.AppSettings["ConnectionString"].ToString();
        SqlConnection connect = new SqlConnection(strCon);
        connect.Open();
        //string strCon = "Data Source=.;Initial Catalog=LUPS;User ID=sa;pwd=sa";//ConfigurationSettings.AppSettings["ConnectionString"].ToString();
        DataSet ds = new DataSet();
        da = new SqlDataAdapter(sql, connect);
        da.Fill(ds, "r");
        connect.Close();
        connect.Dispose();
        return (ds);
    } 

致谢

Narendra

推荐答案

1-发布完整的错误消息

1 - post the full error message

2-发布您的连接字符串,我怀疑它是问题的一部分

2 - post your connection string, I suspect it''s part of the issue

3-对我们来说,不要告诉我们这很紧急,而不必告诉我们.您会获得免费的帮助,并且没有人会因为您的乞求而更快或更进一步地为您提供帮助.

3 - don''t tell us it''s urgent, it''s not, to us. You''re getting free help, and no-one is going to help you quicker, or more, because you begged.


这篇关于从另一台机器访问智能客户端应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆