请教微软全球技术中心工程师以及所有.net的高手?

duanzj 2002-08-05 02:31:36
我用.net odbc连接mysql数据库,并且将查询数据的结果放在dataset中。
如果表中包含可空的varchar类型的字段,只要该字段的值为''(空字符串,不是null),则dataset总是为空,无结果。(如果将''改为其他有意义的字符或null,则结果可以出来)。
请教高手帮我解答这个问题?
...全文
90 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
duanzj 2002-10-10
  • 打赏
  • 举报
回复
Ok!
Let me describe my problem:

I'm trying to do simple connection with my database using ODBC.NET.
For that, I have created a very simple ASP.NET application under
Visual Studio.NET and I have placed the following code under a
button's onclick event.
---------
OdbcConnection cn;
OdbcCommand cmd;
string MyString;
MyString="Select * from table_name";
cn= new OdbcConnection("dsn=DSN_Name;UID=dba;PWD=sql;");
cmd=new OdbcCommand(MyString,cn);
try
{
cn.Open();
EnvMessage.Text = "Connected..";
}
catch(Exception ex)
{
EnvMessage.Text = "Failied. " + ex.ToString();
}
cn.Close();
-----------

table_name - I'm using a valid database table name.
DSN_Name - I'm using a valid DSN name that I have been using for my
windows application.

I'm getting the following errror.
------
Microsoft.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC
Driver Manager]
Data source name not found and no default driver specified at
Microsoft.Data.Odbc.OdbcConnection.Open()
at DSCOdbcConnection.WebForm1.Connect_Click(Object sender, EventArgs
e)
in c:\inetpub\wwwroot\dscodbcconnection\webform1.aspx.cs:line 96
------

If I create a Windows application instead of ASP.NET application, it
works just fine. It's connected with database. But ASP.NET application
throws the above error message.

Any help? I appreciate your help.

I'm here using DSN method to connect. Please help with correct
connection string.
Tongls 2002-09-05
  • 打赏
  • 举报
回复
你在MySQL里用同样的语句可以查询吗? 如果可以,就应该没有问题 ? 不过,我感觉ADO.NET 是不稳定的!用OLEDBCommandBuilder时,老是说你的SelectCommand 只读,不能生成UpDateCommand或是InsertCommand!
junqiang 2002-09-04
  • 打赏
  • 举报
回复
和数据库系统有关系!
hobo_boy 2002-08-15
  • 打赏
  • 举报
回复
是不是你的代码有问题,看看代码?
yohomonkey 2002-08-14
  • 打赏
  • 举报
回复
不会!看看代码!
spring_ok 2002-08-13
  • 打赏
  • 举报
回复
应该不会吧。
dragon2002 2002-08-13
  • 打赏
  • 举报
回复
数据库或驱动程序可能默认为空,或不支持!!!

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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