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

VB.NET

    Next

  • 1. How to serialize data in WinCE platform
    Hi how can i do for this proble I want to serialize data to a file We can use XmlSerialization in PC platform , as below 'Create a serialize Dim serializer As New XmlSerializer (Me.GetType serializer.Serialize(... But there is no XmlSerializer class , when I develope in WinCE .NET platform Is there any class to do it thanks!
  • 2. RowFilter?
    Dear friends Do somebody see what is wrong with this?: myDataView.RowFilter = "fldDate Is Not Null And fldDate<" & System.DateTime.Today Regards Able
  • 3. Can .NET Class Lib's be used by Non .NET Apps?
    Just wondering...If I create a class library using VB.NET, can non-.NET languages use it?...such as LCC32?

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

Postby aniket_sp » Thu, 05 Jan 2006 02:52:51 GMT

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
        Try
            If OleDbConnection1.State = ConnectionState.Closed Then
                OleDbConnection1.Open()
            Else
                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
            MsgBox(ex.Message)
        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
        DataSet11.Tables("Table1").Rows.Add(dr)
        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) "


Re: problem with data adapter and data set while inserting and retrieving data

Postby Cindy Winegarden » Thu, 05 Jan 2006 04:14:38 GMT

Hi aniket_sp,

What is the value of rno when you arrive in FillData ?

-- 
Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP
 XXXX@XXXXX.COM   www.cindywinegarden.com







....



Re: problem with data adapter and data set while inserting and retrieving data

Postby aniket_sp » Thu, 05 Jan 2006 04:20:33 GMT

i initialised it to 0.......it didnt work coz the error mesage is
"there is no row present at position 0" then i intialised to same other
value.....now the message "there is no row present at position (the
number i initialsed)".........and even if i do not initialise it still
the problem persists


Re: problem with data adapter and data set while inserting and retrieving data

Postby Marina » Thu, 05 Jan 2006 05:17:44 GMT

Is that the entire contents of filldata, that snippet you posted?

Also, right before you call filldata, what is 
DataSet11.Tables("Table1").Rows.Count?








Re: problem with data adapter and data set while inserting and retrieving data

Postby Cindy Winegarden » Thu, 05 Jan 2006 12:51:03 GMT

Let me get this straight. You enter values into the text boxes on your form 
and then click your Insert button. Clicking the Insert button adds a row and 
populates its values from the boxes on your form. Presumably each time you 
click the button you add another row to your dataset, and each of these rows 
will have a new row number. Right so far?

After you add your row and populate its values you call FillData.

I'm really not sure what FillData is supposed to do. You've just set values 
in your row from the boxes on your form and in FillData it looks like you're 
setting the values for the boxes on the form from the values in the row. 
Wouldn't the boxes already have those values, or are you perhaps trying to 
set the boxes back to some sort of default value from some row that's always 
the same?

How does FillData know what the value of rno is supposed to be unless you 
pass it in as a parameter?

-- 
Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP
 XXXX@XXXXX.COM   www.cindywinegarden.com









Re: problem with data adapter and data set while inserting and retrieving data

Postby aniket_sp » Thu, 05 Jan 2006 16:10:48 GMT








DataSet11.Tables("Table1").Rows.Count??
its not .count but its (rno)...rno is the row no......and it is being
passed as a parameter after initialsing it to some value......when
filldata is called it is supposed to fill the data into the data
set....intially text boxes are bound to the respective locations of the
.mdb database........then a call to filldata is placed after which
updations to the database from the dataset named DATASET 11.......the
error is related to sytem.data.dll......but i dont find a clue to it.


Similar Threads:

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

Here's what I'm trying to do:

1. Create a data adapter with Select and Insert commands.

2. Use DataTableMappings to map XML tags into columns in a 
data base table.

3. Create a dataset

3. Read in a schema using dataset.ReadXmLSchema

4. Read in an xml file that contains the data using 
dataset.Read XML

5. Add 3 new columns to the dataset. (These columns have 
already been mapped in step 2).

6. Put data in the 3 new columns.

7. Modify some data in the other columns using xpath 
queries to find the nodes that need changing.

8. Use datadapter.update(dataset, tablename)

Everything seems to work fine until step 8. I get all the 
data, the extra columns get added, and the data in other 
columns gets modified. When I execute step 8 I get:

Run-time exception thrown : 
System.InvalidOperationException - Cannot add or remove 
columns from the table once the DataSet is mapped to a 
loaded XML document.

Any ideas about how I can either fix this or do it another 
way.

TIA,
Candi

2.Table adapters vs. Data adapters

Newbie question.

What is the difference?  Why would I use one over the other?


3.retrieving textbox form data from an ENCTYPE=multipart/form-data form

4.Dll to send data wait 6 seconds then retrieve data

What is the best way to have the server execute code wait 6 seconds then 
execute more code?  

Code posts credit card data, waits 6 seconds, then retrieves transaction 
status.  All the code works except for the waiting part.  I concerned about 
multiple connections at the same time waiting for a transaction status.  I 
don want any connections dropped if one connection is waiting for a 
transaction status.

VB6 complied DLL
Running in Class Module
Instancing = 5 MultiUse
MTSTranscationMode = 1 NoTransactions
Persistable = 0 NotPersistable

Project Properties
	Checked Unattended Execution
	Checked Upgrade ActiveX Control
	Checked Retained in Memory
	Threading Model = Apartment Threaded

5.Crystal Reports retrieves wrong data with ODBC drivers, and correct data with Sybase drivers

Hi,

The problem is:

I have my crystal report(version 10 ) running fine and giving me
correct data on the report This is when I use the Syabse driver to
connect to my Sybase database. But Now, I want to use ODBC instead of
Sybase - but when I use ODBC driver the data what is displayed on the
reports is wrong as compared to earlier, when I was using the Syabse
driver.
(I am using a stored procedure which fetches data to my report)

Nothing changes here the not the database, parameter, and nor the
tables everything is same except the mode of connection to the
database.

Can anyone suggest as in how to overcome this problem?

Thanks in advance.
Niks

6. no data retrieved by ADO Data control (msadodc.ocx)

7. Remote Data Control not consistantly retrieving data

8. I am using ADO to retrieve data but it overwrites with ADO data



Return to VB.NET

 

Who is online

Users browsing this forum: No registered users and 25 guest