c#中的代码说明 [英] Explanation of code in c#

查看:64
本文介绍了c#中的代码说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我尝试使用这样的东西时





Hi,

When I am trying to use some thing like this


OleDbDataAdapter command = new OleDbDataAdapter();

               command.Fill(dataSet);
               connection.Close();





我收到如下例外情况。

详细信息:SelectCommand属性没有在调用'Fill'之前已经初始化了



如何解决这个问题?





谢谢

John



I am getting a exception like below.
Details: The SelectCommand property has not been initialized before calling 'Fill'

How to solve this problem??


Thanks
John

推荐答案

一个是
command.SelectCommand = "Your query";





和第二个是数据库的连接路径



and second is connection path to your database


你得到的错误是非常自我解释的:你在尝试调用其Fill()方法之前,必须初始化命令变量的 SelectCommand 属性。

这样:

The error you get is pretty self explanatory: you have to initialize the SelectCommand property of your command variable before trying to call its Fill() method.
This way:
command.SelectCommand = "SELECT [myField] FROM [IShouldReadErrorMessagesMoreCarefully]";


请访问此站点: OLEDB教程(C#) [ ^ ]。你会找到你想要的东西;)
Please, visit this site: OLEDB Tutorial (C#)[^]. There you'll find what you're looking for ;)


这篇关于c#中的代码说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆