Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too many arguments to public sub new() when compiling

Status
Not open for further replies.

JPimp

Technical User
Mar 27, 2007
79
0
0
US
I have this code(which works great in other projects), but in this page, I cannot get this code to compile without the error "Too many arguments to public sub new()"

Dim objConn As New SqlConnection(StrConnString)

Dim cmdSelect

objConn.Open()

cmdSelect = New SqlCommand("Select email From Users where Username = '" & UserName & "'", objConn)

Dim dt As DataTable
Dim da As SqlClient.SqlDataAdapter
dt = New DataTable("Users")

da = New SqlClient.SqlDataAdapter(cmdSelect)
da.Fill(dt)


What am I doing wrong???
 
Perhaps you need to declare the cmdSelect with a specific type:
Code:
Dim cmdSelect As SqlCommand
 
It shows me an error on dt = New DataTable("Users") and then again on da.Fill(dt)

Thanks!
 
Try this:

dt = New DataTable

da = New SqlClient.SqlDataAdapter(cmdSelect)
da.Fill(dt, "Users")

Also, do what mansii said, and Dim the cmdSelect as SqlCommand.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Awesome, much better! Now I think I am finding the root, it says that this: da.Fill(dt, "Users")

Cannot be converted to system.data.dataset, so there is something in the code or class that is still wrong...

Thanks again guys!
 
I ended up moving the code to another project, which compiled without errors?? Now I am getting an outofrange error message on this line:

objMail.To = CStr(DataBinder.Eval(dt, "defaultview.[0].Email"))

Index 0 is either negative or above rows count

So, I assume it is not reading a value from my query:

cmdSelect = New SqlCommand("Select Email From Users where UserName = '" & UserName & "'", objConn)

I checked the query and it does have a value for the field Email where the username = ....,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top