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
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) "
2.Need help with populating table control with data from a data set
Hi,
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:TableRow>
<asp:TableCell Text="Company" ID="CompanyCode"
Runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="Paygroup" ID="PaygroupCode"
Runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="paygroup descr" ID="PaygroupDescr"
Runat="server"></asp:TableCell>
</asp:TableRow>
------------
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.
Thanks,
Gavin
--
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:
>
> UNIQUE IDENTIFIER - or GUID
> 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
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> 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
Hi,
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.