Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C语言中的类库打包System.Data.SqlClient#_C#_Class Library_Sqlclient - Fatal编程技术网

C# 使用C语言中的类库打包System.Data.SqlClient#

C# 使用C语言中的类库打包System.Data.SqlClient#,c#,class-library,sqlclient,C#,Class Library,Sqlclient,我有一个使用C#的扫描仪插件 我的代码可以在模拟器上运行,但不能在扫描仪硬件上运行。可能是因为扫描仪上没有System.Data.SqlClient吗?我不确定。有没有办法指定System.Data.SqlClient包含在生成的dll文件中 我得到的错误名为con.Open()上的管道提供程序错误40。如果扫描器没有库是一个问题,那么在第一次引用SqlConnection时它不会抛出错误吗?源代码如下: String clientName = ""; try

我有一个使用C#的扫描仪插件

我的代码可以在模拟器上运行,但不能在扫描仪硬件上运行。可能是因为扫描仪上没有System.Data.SqlClient吗?我不确定。有没有办法指定System.Data.SqlClient包含在生成的dll文件中

我得到的错误名为con.Open()上的管道提供程序错误40。如果扫描器没有库是一个问题,那么在第一次引用SqlConnection时它不会抛出错误吗?源代码如下:

String clientName = "";

        try
        {
            // Setting up the SqlConnectionStringBuilder
            SqlConnectionStringBuilder buildIt = new SqlConnectionStringBuilder();
            buildIt.DataSource = "xxx.xx.x.xx";
            buildIt.InitialCatalog = "database";
            buildIt.IntegratedSecurity = true;

            using (SqlConnection con = new SqlConnection(buildIt.ConnectionString))
            {
                con.Open();
                using (SqlCommand command = new SqlCommand("SELECT First_Name, Last_Name FROM background WHERE Patient_No=@Patient_No", con))
                {
                    command.Parameters.AddWithValue("@Patient_No", clientID);
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        clientName = reader.GetString(0).Trim() + " " + reader.GetString(1).Trim();
                    } // end if (reader.hasRows)
                    else
                    {
                        // No client found for this ID.
                        return false;
                    } // end else
                } // end using (SqlCommand command = new SqlCommand("SELECT First_Name, Last_Name FROM background WHERE Patient_No=@Patient_No", con))
            }
        } // end try
        catch (Exception err)
        {
            // Test code.
            // MessageBox.Show(err.Message);
            exporterHost.WriteSystemLog(LogType.Error, "E9999999", "SQL ERROR: " + err.Message);
            return false;
        }

谢谢

System.Data.SqlClient是System.Data.dll的一部分。我在我的项目中引用了它。有没有办法将其包含在编译的.dll文件中?System.Data.dll是框架的一部分,您不需要将其打包到应用程序中听起来更像是一个简单的连接问题。您的数据库无法通过命名管道访问。如果所需的类/程序集等不可用,例外情况会这样说。感谢您的输入。令人困惑的是,它可以在扫描仪模拟器上工作,但不能在扫描仪硬件上工作。