Redian新闻
>
关于SqlDataAdapter的初级问题求助
avatar
关于SqlDataAdapter的初级问题求助# DotNet - 窗口里的风景
s*y
1
在程序中写下SqlDataAdapter adp = new SqlDataAdapter
编译时出错,说是
"System.Data.DataClient.SqlDataAdapter" denotes
a 'class' which is not valid in the given context.
哪位大侠知道是怎么回事?望不吝赐教。先行谢过
avatar
a*y
2

~~~~~

【在 s***y 的大作中提到】
: 在程序中写下SqlDataAdapter adp = new SqlDataAdapter
: 编译时出错,说是
: "System.Data.DataClient.SqlDataAdapter" denotes
: a 'class' which is not valid in the given context.
: 哪位大侠知道是怎么回事?望不吝赐教。先行谢过

avatar
s*y
3
您是说要加参数?请详细一点好么,谢谢了

【在 a********y 的大作中提到】
:
: ~~~~~

avatar
a*y
4
No.
I thought you forgot the "()".
avatar
C*n
5
NBBBBBBBBBBB
连这你都能看出来. 如果我是RECRUITER, you got the job already. :-)

【在 a********y 的大作中提到】
: No.
: I thought you forgot the "()".

avatar
a*y
6
//hand.
avatar
s*y
7
But I have the "()".confused

【在 a********y 的大作中提到】
: No.
: I thought you forgot the "()".

avatar
p*n
8
did you set the parameters afterwards?

【在 s***y 的大作中提到】
: But I have the "()".confused
avatar
a*y
9
I think it must be syntax error.
The error says there is no such class in context.
BTW, please check if you have using that namespace.

【在 p***n 的大作中提到】
: did you set the parameters afterwards?
avatar
s*y
10
I have "using System.Data.Sqlclient"
and "using System.Data" and etc
Let me post the whole Page_Load method and see if there's anything wrong.
It's a really simple method though.
private void Page_Load(........)
{
SqlConnection conn = new SqlConnection(........);
SqlCommand cmd = new SqlCommand (.......);
SqlDataAdapter adp = new SqlDataAdapter(); //error this line
adp.SelectCommand = cmd;
DataSet ds = new DataSet();
adp.Fill(ds,"Database1");
...
}
Then the comile-time error occurs.

【在 a********y 的大作中提到】
: I think it must be syntax error.
: The error says there is no such class in context.
: BTW, please check if you have using that namespace.

avatar
a*y
11






<img border="0" src="/moin_static193/solenoid/img/up.png" style="vertical-align:top;"/><br/><span class="zt-cite">: I have "using System.Data.Sqlclient"<br/>: and "using System.Data" and etc<br/>: Let me post the whole Page_Load method and see if there's anything wrong.<br/>: It's a really simple method though.<br/>: private void Page_Load(........)<br/>: {<br/>: SqlConnection conn = new SqlConnection(........);<br/>: SqlCommand cmd = new SqlCommand (.......);<br/>: SqlDataAdapter adp = new SqlDataAdapter(); //error this line<br/>: adp.SelectCommand = cmd;</span><br/>

a********y
发帖数: 20
12
namespace HowTo.Samples.ADONET
{
using System;
using System.Data.SqlClient;
public class adooverview2
{
public static void Main()
{
adooverview2 myadooverview2 = new adooverview2();
myadooverview2.Run();
}
public void Run()
{
string Message = null;
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;T
rusted_Connection=yes;database=northwind");
SqlCommand mySqlCommand = new SqlCommand("INSERT INTO Customers (Custome
rId, CompanyName, ContactName,

【在 s***y 的大作中提到】
: I have "using System.Data.Sqlclient"
: and "using System.Data" and etc
: Let me post the whole Page_Load method and see if there's anything wrong.
: It's a really simple method though.
: private void Page_Load(........)
: {
: SqlConnection conn = new SqlConnection(........);
: SqlCommand cmd = new SqlCommand (.......);
: SqlDataAdapter adp = new SqlDataAdapter(); //error this line
: adp.SelectCommand = cmd;

C****n
发帖数: 2324
13

is this System.Data.DataClient.SqlDataAdapter wrong?
It should be System.Data.SqlClient.SqlDataAdapter.
Which version of VS do you use?
You'd better paste your whole file here.
I feel AsianHotty's assumption is pretty reasonable. :-)

【在 s***y 的大作中提到】
: 在程序中写下SqlDataAdapter adp = new SqlDataAdapter
: 编译时出错,说是
: "System.Data.DataClient.SqlDataAdapter" denotes
: a 'class' which is not valid in the given context.
: 哪位大侠知道是怎么回事?望不吝赐教。先行谢过

e***g
发帖数: 158
14
how come a compilation be a problem, hehe
a**y
发帖数: 335
15

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think i use System.Data.SqlClient.SqlDataAdapter

【在 s***y 的大作中提到】
: 在程序中写下SqlDataAdapter adp = new SqlDataAdapter
: 编译时出错,说是
: "System.Data.DataClient.SqlDataAdapter" denotes
: a 'class' which is not valid in the given context.
: 哪位大侠知道是怎么回事?望不吝赐教。先行谢过

k*****y
发帖数: 221
16
.NET有时候会报错行,至少我已经遇到过一次了。
明明是类型不匹配,它告诉我找不到邮CMO Object.
如果实在在那行找不到错误,最好到其他位置也看看。

【在 s***y 的大作中提到】
: But I have the "()".confused
avatar
a*y
12
namespace HowTo.Samples.ADONET
{
using System;
using System.Data.SqlClient;
public class adooverview2
{
public static void Main()
{
adooverview2 myadooverview2 = new adooverview2();
myadooverview2.Run();
}
public void Run()
{
string Message = null;
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;T
rusted_Connection=yes;database=northwind");
SqlCommand mySqlCommand = new SqlCommand("INSERT INTO Customers (Custome
rId, CompanyName, ContactName,

【在 s***y 的大作中提到】
: I have "using System.Data.Sqlclient"
: and "using System.Data" and etc
: Let me post the whole Page_Load method and see if there's anything wrong.
: It's a really simple method though.
: private void Page_Load(........)
: {
: SqlConnection conn = new SqlConnection(........);
: SqlCommand cmd = new SqlCommand (.......);
: SqlDataAdapter adp = new SqlDataAdapter(); //error this line
: adp.SelectCommand = cmd;

avatar
C*n
13

is this System.Data.DataClient.SqlDataAdapter wrong?
It should be System.Data.SqlClient.SqlDataAdapter.
Which version of VS do you use?
You'd better paste your whole file here.
I feel AsianHotty's assumption is pretty reasonable. :-)

【在 s***y 的大作中提到】
: 在程序中写下SqlDataAdapter adp = new SqlDataAdapter
: 编译时出错,说是
: "System.Data.DataClient.SqlDataAdapter" denotes
: a 'class' which is not valid in the given context.
: 哪位大侠知道是怎么回事?望不吝赐教。先行谢过

avatar
e*g
14
how come a compilation be a problem, hehe
avatar
a*y
15

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think i use System.Data.SqlClient.SqlDataAdapter

【在 s***y 的大作中提到】
: 在程序中写下SqlDataAdapter adp = new SqlDataAdapter
: 编译时出错,说是
: "System.Data.DataClient.SqlDataAdapter" denotes
: a 'class' which is not valid in the given context.
: 哪位大侠知道是怎么回事?望不吝赐教。先行谢过

avatar
k*y
16
.NET有时候会报错行,至少我已经遇到过一次了。
明明是类型不匹配,它告诉我找不到邮CMO Object.
如果实在在那行找不到错误,最好到其他位置也看看。

【在 s***y 的大作中提到】
: But I have the "()".confused
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。