ODBC连接问题 我在做ODBC连接informix数据库的时候不知道odbcconnection.connectionstring的连接语句这么写请指教我一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Informix ODBC Informix 3.30:"Dsn='';Driver={INFORMIX 3.30 32 BIT};Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb;UID=username;PWD=myPwd Informix-CLI 2.5:"Driver={Informix-CLI 2.5 (32 Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd" DSN ODBC DSN:"DSN=myDsn;Uid=username;Pwd=;" File DSN:"FILEDSN=c:\myData.dsn;Uid=username;Pwd=;" http://www.csdn.net/develop/article/16/16437.shtm 大家帮忙看看我的程序错在什么地方好吗?运行在(r = this.odbcCommand1.ExecuteReader();)提示系统错误namespace WindowsApplication2{ /// <summary> /// DataForm1 的摘要说明。 /// </summary> public class DataForm1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private Microsoft.Data.Odbc.OdbcConnection odbcConnection1; private Microsoft.Data.Odbc.OdbcCommand odbcCommand1; private System.Windows.Forms.ListBox listBox1; private System.Data.SqlClient.SqlConnection sqlConnection1; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public DataForm1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.odbcConnection1 = new Microsoft.Data.Odbc.OdbcConnection(); this.odbcCommand1 = new Microsoft.Data.Odbc.OdbcCommand(); this.listBox1 = new System.Windows.Forms.ListBox(); this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(88, 8); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // odbcConnection1 // this.odbcConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" + "ue;user id=ccx99"; // // odbcCommand1 // this.odbcCommand1.Connection = this.odbcConnection1; // // listBox1 // this.listBox1.ItemHeight = 12; this.listBox1.Location = new System.Drawing.Point(80, 64); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(120, 88); this.listBox1.TabIndex = 1; // // sqlConnection1 // this.sqlConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" + "ue;user id=ccx99"; // // DataForm1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.listBox1, this.button1}); this.Name = "DataForm1"; this.Text = "DataForm1"; this.ResumeLayout(false); } #endregion private void button1_Click(object sender, System.EventArgs e) { string sql = "select * from ybwl"; Microsoft.Data.Odbc.OdbcDataReader r; this.odbcCommand1.CommandText = sql; this.odbcConnection1.Open(); //int i = 0; //i = this.odbcCommand1.ExecuteNonQuery(); //MessageBox.Show(i.ToString()); r = this.odbcCommand1.ExecuteReader(); MessageBox.Show(r[0].ToString()); this.odbcConnection1.Close(); } }} 我建立的ODBC没有问题,在服务器资源管理器上能看到的this.odbcConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" + "ue;user id=ccx99";上面语句的data source=??? 是我的ODBC名称吗? Intelligencia.UrlRewriter问题,高手请进 龙年大礼包,完整的im源码喜欢研究的朋友下载 怎么能查出用户名?急 贵阳的兄弟进来,散分咯! C#中如何使用API 请问一命令形式执行存储过程能获取返回值吗? 急求在线考试系统中试题 如何用Repeater 分页,点上下页还能保存上页所选答案?祝大家新年快乐 怪事!发现四舍五入的新问题(有代码) 100分!!!我的计算机是域控制器,是否就是C#WEB应用运行时会出现HTTP500内部服务器错误原因? 一段简单的代码问题。 如何在用FileStream作拷贝时判断是否在进行? 在线等待:字符串连接的问题
ODBC
Informix 3.30:
"Dsn='';Driver={INFORMIX 3.30 32 BIT};Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb;UID=username;PWD=myPwd
Informix-CLI 2.5:
"Driver={Informix-CLI 2.5 (32 Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd"
DSN
ODBC
DSN:
"DSN=myDsn;Uid=username;Pwd=;"
File DSN:
"FILEDSN=c:\myData.dsn;Uid=username;Pwd=;"
{
/// <summary>
/// DataForm1 的摘要说明。
/// </summary>
public class DataForm1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private Microsoft.Data.Odbc.OdbcConnection odbcConnection1;
private Microsoft.Data.Odbc.OdbcCommand odbcCommand1;
private System.Windows.Forms.ListBox listBox1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public DataForm1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.odbcConnection1 = new Microsoft.Data.Odbc.OdbcConnection();
this.odbcCommand1 = new Microsoft.Data.Odbc.OdbcCommand();
this.listBox1 = new System.Windows.Forms.ListBox();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 8);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// odbcConnection1
//
this.odbcConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" +
"ue;user id=ccx99";
//
// odbcCommand1
//
this.odbcCommand1.Connection = this.odbcConnection1;
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(80, 64);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 88);
this.listBox1.TabIndex = 1;
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" +
"ue;user id=ccx99";
//
// DataForm1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listBox1,
this.button1});
this.Name = "DataForm1";
this.Text = "DataForm1";
this.ResumeLayout(false); }
#endregion private void button1_Click(object sender, System.EventArgs e)
{
string sql = "select * from ybwl";
Microsoft.Data.Odbc.OdbcDataReader r;
this.odbcCommand1.CommandText = sql;
this.odbcConnection1.Open();
//int i = 0;
//i = this.odbcCommand1.ExecuteNonQuery();
//MessageBox.Show(i.ToString());
r = this.odbcCommand1.ExecuteReader();
MessageBox.Show(r[0].ToString());
this.odbcConnection1.Close();
}
}
}
this.odbcConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" +
"ue;user id=ccx99";
上面语句的data source=??? 是我的ODBC名称吗?