s***y 发帖数: 352 | 1 在程序中写下SqlDataAdapter adp = new SqlDataAdapter
编译时出错,说是
"System.Data.DataClient.SqlDataAdapter" denotes
a 'class' which is not valid in the given context.
哪位大侠知道是怎么回事?望不吝赐教。先行谢过 |
a********y 发帖数: 20 | 2
~~~~~
【在 s***y 的大作中提到】 : 在程序中写下SqlDataAdapter adp = new SqlDataAdapter : 编译时出错,说是 : "System.Data.DataClient.SqlDataAdapter" denotes : a 'class' which is not valid in the given context. : 哪位大侠知道是怎么回事?望不吝赐教。先行谢过
|
s***y 发帖数: 352 | 3 您是说要加参数?请详细一点好么,谢谢了
【在 a********y 的大作中提到】 : : ~~~~~
|
a********y 发帖数: 20 | 4 No.
I thought you forgot the "()". |
C****n 发帖数: 2324 | 5 NBBBBBBBBBBB
连这你都能看出来. 如果我是RECRUITER, you got the job already. :-)
【在 a********y 的大作中提到】 : No. : I thought you forgot the "()".
|
a********y 发帖数: 20 | |
s***y 发帖数: 352 | 7 But I have the "()".confused
【在 a********y 的大作中提到】 : No. : I thought you forgot the "()".
|
p***n 发帖数: 635 | 8 did you set the parameters afterwards?
【在 s***y 的大作中提到】 : But I have the "()".confused
|
a********y 发帖数: 20 | 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?
|
s***y 发帖数: 352 | 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.
|
|
|
a********y 发帖数: 20 | 11 <%@ Page Language="C#" Debug="true" Src="adooverview2.cs"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="HowTo.Samples.ADONET" %>
: 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;
| 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
|
|