高分请教.net 连接sysbase问题

postfxj 2013-12-24 10:29:03
环境:
客户端版本:SYBASE_ASE15.7CLEINT_32
三个dll文件为:
Sybase.Data.AseClient.dll(版本号为:1.1.327.0),
sybdrvado11.dll(版本号为:1.1.327.0),
sybdrvssl.dll(版本号为12.5.1.327)
代码如下:


private void buttonConnect_Click(object sender, System.EventArgs e)
{
// obtain the connection information specified
String host = textBoxHost.Text;
String port = textBoxPort.Text;
String user = textBoxUser.Text;
String pass = textBoxPass.Text;

// build a connect string
string connStr = "Data Source=\'" + host + "\';Port=\'" + port + "\';UID=" + user + ";PWD=\'" + pass + "\';Database=\'pubs2\';";

_conn = new AseConnection( connStr );
// if tracing has been enabled, setup tracing
if(checkTrace.Checked)
{
// create the trace file
_fs = new FileStream("trace.log", FileMode.Create, FileAccess.Write);
_strmWriter = new StreamWriter(_fs);

_strmWriter.WriteLine("************ Sybase ASE ADO.NET Data Provider Trace start ****************");
indentLevel = 0;

// register the trace event handlers
_conn.TraceEnter += new TraceEnterEventHandler(TraceEnter);
_conn.TraceExit += new TraceExitEventHandler(TraceExit);
}

try
{
_conn.Open();
Setup();
buttonExecute.Enabled = true;
buttonConnect.Enabled = false;
}
catch (AseException ex)
{
MessageBox.Show(ex.Source + " : " + ex.Message + " (" + ex.ToString() + ")", "Failed to connect");
}
}

private void Setup()
{
//setup
try
{
AseCommand dropCmd = new AseCommand(strDropProc, _conn);
dropCmd.ExecuteNonQuery();
}
catch(AseException)
{
//If the proc does not exist we expect this exception
}

AseCommand createCmd = new AseCommand(strCreateProc, _conn);
createCmd.ExecuteNonQuery();
}


在_conn = new AseConnection( connStr );连接实例化时报错,错误如下:
System.TypeInitializationException: 'Sybase.Data.AseClient.AseConnection' 的型別初始設定式發生例外狀況。 ---> System.DllNotFoundException: 無法載入 DLL 'sybdrvado11.dll': 找不到指定的模組。 (發生例外狀況於 HRESULT: 0x8007007E)
於 Sybase.Data.AseClient.Unmanaged.AseGetDriverVersion(StringBuilder value, Int32 capacity)
於 Sybase.Data.AseClient.AseConnection.CheckVersion()
於 Sybase.Data.AseClient.AseConnection..cctor()
--- 內部例外狀況堆疊追蹤的結尾 ---
...全文
206 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
postfxj 2013-12-27
  • 打赏
  • 举报
回复
还真没有多少人研究过哟
postfxj 2013-12-24
  • 打赏
  • 举报
回复
我安装客户端自定义安装,全打上勾了,一个没有落下。
  • 打赏
  • 举报
回复
缺少其他依赖DLL,你电脑上有没有完整安装sybase?
postfxj 2013-12-24
  • 打赏
  • 举报
回复
有人碰到过吗?
postfxj 2013-12-24
  • 打赏
  • 举报
回复
自己给自己顶起

110,533

社区成员

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

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

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