473,406 Members | 2,633 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,406 software developers and data experts.

Class 'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it has no default property.

Hi,
I'm trying to something quite straightforward, populate a datagrid
with certain fields after selecting from a dropdownlist. The books I
have don't seem to give an example of how to do this ( particularly
from within VStudio 2003 ) and it's driving me to distraction.

daNumber1 selects the au_id and au_lname
SqlDataAdapter1 is attempting to take the parameter @au_id to populate
the datagrid1, but the SqlDataAdapter1 is giving the error "Class
'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it
has no default property." I don't understand what the default ought to
be...

As I say, I have no book examples to work from, so I'm just cobbling
together other bits in an attempt to understand/get it to work -
apologies if my poor code offends thee!

Thanks,
bob

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlConnection1.Open()
daNumber1.Fill(dsNumber1)
If Not Page.IsPostBack Then
lstCategory.DataSource = dsNumber1()
lstCategory.DataValueField = "au_id"
lstCategory.DataTextField = "au_lname"
lstCategory.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
DataGrid1.DataSource =
SqlDataAdapter1(lstCategory.SelectedValue)
DataGrid1.DataBind()
End Sub
Nov 18 '05 #1
1 2507
In your button click perhaps try this:

DataGrid1.DataSource = dsNumber1.Tables[0].Select( "au_id = " +
lstCategory.SelectedValue );
DataGrid1.DataBind();

Now this is dependent on the dsNumber1 being defined globally to the page.
Also, I am assuming dsNumber1 is a DataSet with the first table (zero based
indexes or indii ) having the DataGrid information.

bill
"Bob of the West" <bo*************@yahoo.com> wrote in message
news:3a**************************@posting.google.c om...
Hi,
I'm trying to something quite straightforward, populate a datagrid
with certain fields after selecting from a dropdownlist. The books I
have don't seem to give an example of how to do this ( particularly
from within VStudio 2003 ) and it's driving me to distraction.

daNumber1 selects the au_id and au_lname
SqlDataAdapter1 is attempting to take the parameter @au_id to populate
the datagrid1, but the SqlDataAdapter1 is giving the error "Class
'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it
has no default property." I don't understand what the default ought to
be...

As I say, I have no book examples to work from, so I'm just cobbling
together other bits in an attempt to understand/get it to work -
apologies if my poor code offends thee!

Thanks,
bob

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlConnection1.Open()
daNumber1.Fill(dsNumber1)
If Not Page.IsPostBack Then
lstCategory.DataSource = dsNumber1()
lstCategory.DataValueField = "au_id"
lstCategory.DataTextField = "au_lname"
lstCategory.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
DataGrid1.DataSource =
SqlDataAdapter1(lstCategory.SelectedValue)
DataGrid1.DataBind()
End Sub

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Adams | last post by:
Hi, I am afraid I am asking a very basic question, or just something that is not possible. I have a WinForm app that contains a Form (Form A), and then 20-30 UserControls/WinForms that are...
5
by: Lasse Edsvik | last post by:
Hello Im trying to create a simple testclass that connects to a db on localhost and a method that returns a dataset. I get these errors: Unhandled Exception: System.InvalidOperationException:...
6
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 ...
1
by: Daren Hawes | last post by:
Hi, I have a class called Jobs. In that class is the function below.. Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID As Integer) As DataSet ' Setup the Stored...
5
by: Shapper | last post by:
Hello, I am working in a web site where all the code is placed in aspx.vb files. After a while I realized that many functions included in my aspx.vb files where common to all pages. I...
4
by: Mark | last post by:
I'd like to take an instance of a class and store it in a database. I've marked my class as and am using the binary formatting code similar to...
3
by: Stacey Levine | last post by:
I have a webservice that has the below procedure. Basically a procedure to called a stored procedure and return the results. When I try to call the webservice from my program I get the error. Both...
7
by: tshad | last post by:
I have a problem with a VS 2003 project. This project was designed and works fine in VS 2003. But trying to open the project I get the following error....
1
by: Arpan | last post by:
A class file named "SecureDBWS.vb" exsting in C:\Inetpub\wwwroot\ASPX\Business folder has the following code: Imports System Imports System.Data Imports System.Data.SqlClient Imports...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.