can data be retrieved from a data set or do I need to use a da

dotnet framework


  • 1. where is IDbException
    Hi, I have done a bit of programming against the System.Data.SqlClient classes but in order to maintain some prospect of database portability in my code I would prefer to use the more general IDbConnection, IDbCommand etc. However, I notice there is no corresponding IDbException, and the documentation for the IDbXXX interfaces does not mention any exceptions that might be thrown. Am I correct in thinking that using the more general IDbXXX interfaces is a good practice? - it seems silly to tie myself unnecessarily to one database provider implementation? If so, how should I manage database exceptions? Thanks in advance for any responses. Even if there is no nice answer, it would be good to know that I'm not overlooking something obvious Andy
  • 2. Coding ADO in VB.Net environment
    Hi, I am upgrading my database componenet from VB6.0 to but would like to use ADO for database operation. Am trying to retrieve no of tables in a database using connection.openschema method of ADODB. It works fine in VB6.0 but blows of in The code looks like rsReadOnly = New ADODB.Recordset rsReadOnly = goConnection.OpenSchema(ADODB.SchemaEnum.adSchemaTables, New Object() {Nothing, Nothing, Nothing, "TABLE"}) The Error message is :System.NullReferenceException - Object variable or With block variable not set. Very Urgent........ -- System Analyst

Re: can data be retrieved from a data set or do I need to use a da

Postby Val Mazur » Fri, 23 Jul 2004 08:27:14 GMT


In this case you could probably just use Select method of the DataTable to 
select all the rows , which match specific condition, into array. For 

Dim loRows() as DataRow

loRows=MyDataSet.Tables(0).Select("INT=2 or INT=4")

Now you will have an array, which will contain all the matching datarows and 
you could analyze this array

Val Mazur
Microsoft MVP

Re: can data be retrieved from a data set or do I need to use a da

Postby UGF1bA » Fri, 23 Jul 2004 08:40:02 GMT

was not aware of how to use the select method, looks quite useful for what I am trying to do. 
Paul G
Software engineer.

Similar Threads:

1.problem with data adapter and data set while inserting and retrieving data

i am using a data adapter and a dataset for filling and retrieving data
into .mdb database.
following is the code.....

for the form load event
  Dim dc(0) As DataColumn
            If OleDbConnection1.State = ConnectionState.Closed Then
                MsgBox("connection can not be established")
            End If
            DA.Fill(DataSet11, "Table1")
            cmd = New OleDbCommandBuilder(DA)
            dc(0) = DataSet11.Tables("Table1").Columns("EmpID")
            DataSet11.Tables("Table1").PrimaryKey = dc
        Catch ex As Exception
        End Try
        Delete.Enabled = False
    End Sub

for  inserting values into the DB

Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Insert.Click
        Dim dr As DataRow
        dr = DataSet11.Tables("Table1").NewRow
        dr.Item(0) = Val(TB1.Text)
        dr.Item(1) = TB2.Text
        dr.Item(2) = TB3.Text
        dr.Item(3) = Val(TB4.Text)
        dr.Item(4) = TB5.Text
        DA.Update(DataSet11, "Table1")
        MsgBox("data is saved")
        rno = 0
        call filldata()

filldata function consists of the following

 With DataSet11.Tables("Table1").Rows(rno)
         TB1.Text = Trim(.Item(0))
         TB2.Text = Trim(.Item(1))
         TB3.Text = Trim(.Item(2))
         TB5.Text = Trim(.Item(4))
         End With

the error it gives is " there is no row at
0........system.nullreference...........i checked the connection and
its working fine and also the database is getting accessed........the
error is occuring at the line " With
DataSet11.Tables("Table1").Rows(rno) "

2.Need help with populating table control with data from a data set


I don't have much knowledge of the table control. I am basically trying to 
use a table thats populated with data rows from a dataSet but currently 
things aren't working for me.

below is the sample HTML that I have:

	<asp:TableCell Text="Company" ID="CompanyCode" 
	<asp:TableCell Text="Paygroup" ID="PaygroupCode" 
	<asp:TableCell Text="paygroup descr" ID="PaygroupDescr" 


In addition, I think I need some VB code to assign the particular data rows 
to the table columns, but I'm not sure of the syntax:

 Table1.ID("Company") = Dr("Company")

Any help would be much appreciated.



You've got to live and learn...

3.PRIMARY KEY required for WRITING data to SQL DATABASE using DA

Hi Gregory,

Even when I added the identity to an int column in the database, I cant use 
it for editing tha datagrid & writing the values back to the SQL database.

I am too confused at the moment.please help

"Cowboy (Gregory A. Beamer) - MVP" wrote:

> Two choices, without much pain:
> IDENTITY column - integer column with IDENTITY set on
> If you need a huge number of records or are spanning work across multiple 
> servers, the UNIQUE IDENTIFIER is better; otherwise, an integer with IDENTITY 
> is generally good enough (can be any type of integer column, AFAIK, although 
> int and bigint are most common).
> ---
> Gregory A. Beamer
> ***************************
> Think Outside the Box!
> ***************************
> "pmud" wrote:
> > I am posting this question here too coz I was not sure whether I had posted 
> > this earlier in the right group.
> > 
> > I need an editable datagrid. But for editing a datagrid as shown in the 
> > walkthrough: Using a DataGrid Web Control to Read and Write Data,  the table 
> > in the SQL database should have a primary key. But my table doesnt have one. 
> > So what is the best way I can create primary key in SQL database? 
> > 
> > Is UNIQUE IDENTIFIER a good option? Is it something like Auro Number of MS 
> > Access which is automatically filled by the database for each row? If not , 
> > how can i make a primary key for that SQL table?
> > 
> > -- 
> > pmud

4.updating a datagrid using a data adpater and data set

5.can data be retrieved from a data set or do I need to use a data t


Do you need to compare values in a different datatables? If yes, then there 
is no direct way to do this, but you could do next thing. If one of the 
table has a primary key then you could relate two datatables and navigating 
through the one table, you could get related records from another one

Val Mazur
Microsoft MVP

"Paul" < XXXX@XXXXX.COM > wrote in message 
news: XXXX@XXXXX.COM ...
>I have a simple data set with 1 column, 3 rows of an integer type.  I need 
>to do a comparison on the data and tried to copy it into an array but the 
>copy method did not seem to work.  I ended up creating a datatable, loading 
>the table with the dataset and then getting the data out of the datatable. 
>Seems like there should be an easier way to do this, comparing with dataset 
>elements directly or data table elements directly.
> thanks.
> Paul G
> Software engineer. 

6. Data Adapters, Data Sets, Data TableMappings, and XML

7. Data Set Base Default Vaules done

8. [Help needed]: Error retrieving data from Web.config.

Return to dotnet framework


Who is online

Users browsing this forum: No registered users and 26 guest