473,618 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class 'System.Data.Sq lClient.SqlData Adapter' 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.Sq lClient.SqlData Adapter' 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.EventArg s) Handles MyBase.Load
SqlConnection1. Open()
daNumber1.Fill( dsNumber1)
If Not Page.IsPostBack Then
lstCategory.Dat aSource = dsNumber1()
lstCategory.Dat aValueField = "au_id"
lstCategory.Dat aTextField = "au_lname"
lstCategory.Dat aBind()
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
DataGrid1.DataS ource =
SqlDataAdapter1 (lstCategory.Se lectedValue)
DataGrid1.DataB ind()
End Sub
Nov 18 '05 #1
1 2517
In your button click perhaps try this:

DataGrid1.DataS ource = dsNumber1.Table s[0].Select( "au_id = " +
lstCategory.Sel ectedValue );
DataGrid1.DataB ind();

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.goo gle.com...
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.Sq lClient.SqlData Adapter' 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.EventArg s) Handles MyBase.Load
SqlConnection1. Open()
daNumber1.Fill( dsNumber1)
If Not Page.IsPostBack Then
lstCategory.Dat aSource = dsNumber1()
lstCategory.Dat aValueField = "au_id"
lstCategory.Dat aTextField = "au_lname"
lstCategory.Dat aBind()
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
DataGrid1.DataS ource =
SqlDataAdapter1 (lstCategory.Se lectedValue)
DataGrid1.DataB ind()
End Sub

Nov 18 '05 #2

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

Similar topics

2
3371
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 created by Form A. Form A calls a class to populate a strongly typed DataSet (contains about 20 tables) that is to be shared amongst the UC's and other Forms. Right now, I am passing this DataSet to each and every UserControl/Form via the...
5
2589
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: Fill: SelectCommand.Conne ction property has not been initialized. at System.Data.Common.DbDataAdapter.GetConnection3(DbDataAdapter adapter, IDb
6
6098
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 I received an error message: "The ConnectionString property has not been initialized.
1
1228
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 Procedure Dim SqlCommand As New SqlCommand Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString) Try SqlCommand.CommandText = "dbo.DeleteJobTitle" SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
5
1331
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 created a new file named common.vb where I created a class named common and where I place all common functions:
4
1448
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconserializationconcepts.asp, although I'd be happy to use something else. What method should be used to store this serialized class in a SQL Server database? Likewise, what method should be used to recreate this...
3
2755
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 my calling code and the webservice code are below. Thanks for your help. D:\Projects .NET\StoreBO\frmVoids.vb(182): Value of type '1-dimensional array of System.Data.SqlClient.SqlParameter' cannot be converted to '1-dimensional array of...
7
4654
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. ************************************************************ The class EmailPoller can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try...
1
1828
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 System.Web.Services Imports System.Web.Services.Protocols Namespace DBSecuritySettingsWS
0
8207
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8150
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8650
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8593
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4064
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2582
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.