473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Overload

147 100+
Hello

I am getting a CS1502: The best overloaded method match for 'System.Data.SqlClient.SqlDataAdapter.SqlDataAdapt er(System.Data.SqlClient.SqlCommand)' has some invalid arguments

I have no idea what I've done wrong!

Expand|Select|Wrap|Line Numbers
  1. string strConn = ConfigurationManager.ConnectionStrings["BoardToBoard"].ConnectionString;
  2.  
  3.         string strB2BSQL = "SELECT * FROM View_BoardToBoard";
  4.  
  5.         SqlConnection B2BConn;
  6.         DataSet ds = new DataSet();
  7.         SqlDataAdapter B2BDA;
  8.  
  9.         B2BConn = new SqlConnection(strConn);
  10.         B2BDA = new SqlDataAdapter(strB2BSQL);
  11.  
  12.         try
  13.         {
  14.             B2BConn.Open();
  15.  
  16.             B2BDA.Fill(ds, "B2B");
  17.  
  18.             grdB2B.DataSource = ds;
  19.             grdB2B.DataBind();
  20.         }
  21.  
  22.         finally
  23.         {
  24.             B2BConn.Close();
  25.         }
Thank you

Dave
Apr 29 '09 #1
8 1595
try making a new SqlDataAdapter the moment you define it by adding
Expand|Select|Wrap|Line Numbers
  1. new SqlDataAdapter();
that should fix it
Apr 29 '09 #2
DaveRook
147 100+
Thank you for the suggestion, but I've changed it a bit now and have something else.

I have used this lots with Acces databases, but this is the first SQL server I'm trying to connect to
Apr 29 '09 #3
what do you have now, could you paste some of the code and tell where the error points to?
Apr 29 '09 #4
DaveRook
147 100+
Sorry, I updated my original Post. What you have at the top of the page is what I have. I will add changes to new posts from now on.

The error is on line 10: B2BDA = new SqlDataAdapter(strB2BSQL);


Thank you
Apr 29 '09 #5
to use a string in a new database you need to include a connection or connectionstring as well, try:
Expand|Select|Wrap|Line Numbers
  1. B2BDA = new SqlDataAdapter(strB2BSQL, B2BConn);
Apr 29 '09 #6
DaveRook
147 100+
Thank you for your help. It worked fine. If you have a minute more, can you tell me why I needed both?

Line 9 B2BConn = new SqlConnection(strConn); already tells it what the connection is so I don't know why I needed to declare it in the SqlDataAdapter as well

Thank you again
Apr 29 '09 #7
(im also quite new to programming, but ill try my best)
a DataAdapter is the bridge between the application and the SQL server, so in order to get the data it needs to know how to connect. for that a connection string or connection object is used.
when you use or create a SqlCommand Object it also asks for a connection.

i hope to have explained it well
Apr 29 '09 #8
DaveRook
147 100+
Superb. Thank you for your help.
Apr 29 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Piotre Ugrumov | last post by:
I have tried to implement the overload of these 2 operators. ostream & operator<<(ostream &out, Person &p){ out<<p.getName()<<" "<<p.getSurname()<<", "<<p.getDateOfBirth()<<endl; return out; }...
1
by: Piotre Ugrumov | last post by:
I'm following your help. I have written the overload of the operator <<. This overload work! :-) But I have some problem with the overload of the operator >>. I have written the overload of this...
3
by: Piotre Ugrumov | last post by:
I have done the overload on the operator >> and << in the class Attore. These 2 overload work correctly. I have done the overload of the same overload in the class Film. The class film ha inside...
4
by: Chiller | last post by:
Ok, thanks to some good assistance/advice from people in this group I've been able to further develop my Distance class. Since previous posts I've refined my code to accept the unit measurement...
9
by: Mario Charest | last post by:
.. Hi, It's possible to overload the operator, but I wonder if it's possible to somehow overload and so forth. My goal would be to switch from static array declaration into something...
17
by: Chris | last post by:
To me, this seems rather redundant. The compiler requires that if you overload the == operator, you must also overload the != operator. All I do for the != operator is something like this: ...
10
by: shachar | last post by:
hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
9
by: Tony | last post by:
I have an operator== overload that compares two items and returns a new class as the result of the comparison (instead of the normal bool) I then get an ambiguous operater compile error when I...
3
by: i3x171um | last post by:
To start off, I'm using GCC4. Specifically, the MingW (setjmp/longjmp) build of GCC 4.2.1 on Windows XP x64. I'm writing a class that abstracts a message, which can be either an integer (stored as...
5
by: jknupp | last post by:
In the following program, if the call to bar does not specify the type as <int>, gcc gives the error "no matching function for call to ‘bar(A&, <unresolved overloaded function type>)’". Since bar...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.