gpt4 book ai didi

C# 使用 Sybase.Data.AseClient.dll 查询 sybase

转载 作者:太空宇宙 更新时间:2023-11-03 11:00:45 25 4
gpt4 key购买 nike

我将 Sybase.Data.AseClient.dll 导入到我的 C# 项目中以连接到 sybase 数据库并查询类似这样的内容

private DataSet query(string jjoprid)
{
string queryStr = "select oprid, oprname,orgid,lastmodified from SA_CXTC_OPRINFO where oprid = \"" + jjoprid + "\";";
DataSet ds ;
try
{
conn = new AseConnection("Data Source=192.168.100.251;database=thq;" +
"charset=cp936;Port=7000;UID=snhqdbo;PWD=janhq@ary");
command = new AseCommand(queryStr, conn);
adapter = new AseDataAdapter(command);
ds = new DataSet();
adapter.Fill(ds);
}
catch (AseException ex)
{
Console.WriteLine(ex.Message);
return null;
}
finally
{
if (null != conn)
conn.Close();
}
return ds ;
}

奇怪的是,我得到了这样的异常

catch Sybase.Data.AseClient.AseException  Message=Character set conversion is not available between client character set 'cp936' and server character set 'iso_1'.  Source=Sybase.Data.AseClient  StackTrace:       at Sybase.Data.AseClient.AseConnectionImpl.CheckResult(Int32 res, Boolean forOpen)       at Sybase.Data.AseClient.AseConnectionImpl.Open()       at Sybase.Data.AseClient.AseConnectionPool.GetConnection(AseConnection conn)       at Sybase.Data.AseClient.AseConnectionPoolManager.GetConnection(String connectionString, AseConnection conn)       at Sybase.Data.AseClient.AseConnection.Open()       System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)       at CXTC运维.Form1.query(String jjoprid) location d:\Documents and Settings\11075452\My Documents\Visual Studio 2010\Projects\CXTC运维\CXTC运维\Form1.cs:行号 41  InnerException: 

显示客户端字符和服务器字符冲突,但我不知道如何解决这个问题,谁能帮我?

谢谢 Parado,我听从了你的建议并得到了这个

catch Sybase.Data.AseClient.AseException  Message=Attempt to locate entry in sysdatabases for database 'thq' by name failed - no entry found under that name. Make sure that name is entered properly.  Source=Sybase.Data.AseClient  StackTrace:       at Sybase.Data.AseClient.AseConnectionImpl.CheckResult(Int32 res, Boolean forOpen)       at Sybase.Data.AseClient.AseConnectionImpl.Open()       at Sybase.Data.AseClient.AseConnectionPool.GetConnection(AseConnection conn)       at Sybase.Data.AseClient.AseConnectionPoolManager.GetConnection(String connectionString, AseConnection conn)       at Sybase.Data.AseClient.AseConnection.Open()       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)       at CXTC运维.Form

最佳答案

尝试将字符集更改为 iso_1,如下所示

conn = new AseConnection("Data Source=192.168.100.251;database=thq;" +
"charset=iso_1;Port=7000;UID=snhqdbo;PWD=janhq@ary");

关于C# 使用 Sybase.Data.AseClient.dll 查询 sybase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17801180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com