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

datarow question

Hey all,

I thought what I was doing was pretty straightforward but apparently not.
All I'm doing is loading a datarow, letting the user modify a field in the
datarow by inputing into a textbox. I then take that textbox and assign the
datarow field that value.

But, as soon as the assignment occurs the datarow becomes nothing. And I
have no idea why.

thanks in advance,
rodchar
Nov 21 '05 #1
5 1379
ok, i think i've narrowed it down. I can use the dr.BeginEdit and the row
updates, but when i try to use dr.EndEdit then the dr becomes nothing again.
rodchar

"rodchar" wrote:
Hey all,

I thought what I was doing was pretty straightforward but apparently not.
All I'm doing is loading a datarow, letting the user modify a field in the
datarow by inputing into a textbox. I then take that textbox and assign the
datarow field that value.

But, as soon as the assignment occurs the datarow becomes nothing. And I
have no idea why.

thanks in advance,
rodchar

Nov 21 '05 #2
Here's some of my syntax:
private sub Save
m_dr.BeginEdit() 'This works
m_dr.Codes = strHold 'This works
m_dr.EndEdit() 'This does not work
End Sub

"rodchar" wrote:
Hey all,

I thought what I was doing was pretty straightforward but apparently not.
All I'm doing is loading a datarow, letting the user modify a field in the
datarow by inputing into a textbox. I then take that textbox and assign the
datarow field that value.

But, as soon as the assignment occurs the datarow becomes nothing. And I
have no idea why.

thanks in advance,
rodchar

Nov 21 '05 #3
Rodchar,

Have a look for databinding and currencymanager for that (it is in the
snippet I showed you with the textbox)

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...ClassTopic.asp

That is a better approach.

I hope this helps?

Cor

"rodchar"
Here's some of my syntax:
private sub Save
m_dr.BeginEdit() 'This works
m_dr.Codes = strHold 'This works
m_dr.EndEdit() 'This does not work
End Sub

"rodchar" wrote:
Hey all,

I thought what I was doing was pretty straightforward but apparently not.
All I'm doing is loading a datarow, letting the user modify a field in
the
datarow by inputing into a textbox. I then take that textbox and assign
the
datarow field that value.

But, as soon as the assignment occurs the datarow becomes nothing. And I
have no idea why.

thanks in advance,
rodchar

Nov 21 '05 #4
Hey Everyone,

Cor, thanks for the articles. I glanced over them and they might be a little
over my head at this time.

Can you take a look at the following code:

Dim _postBack As Boolean = False
Dim _dt As DataSet1.CustomersDataTable
Dim _dr As DataSet1.CustomersRow
Dim arrText() As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
_dt = DataSet11.Customers
ListBox1.DataSource = _dt
ListBox1.DisplayMember = "ContactName"
ListBox1.ValueMember = "CustomerID"
_postBack = True
End Sub

Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedValueChanged
If _postBack = True Then
_dr = _dt.FindByCustomerID(ListBox1.SelectedValue)
FillArray()
TextBox1.Text = arrText(0)
TextBox2.Text = arrText(1)
End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_dr.ContactName = arrText(0) & " " & arrText(1)
MessageBox.Show("Done.")
End Sub

Private Sub FillArray()
arrText = Split(_dr.ContactName, " ")
End Sub
Can you tell me if this is the way to update the contact name?
To run, using Northwind database.
All you need is 1 listbox, 2 textboxes, and a button.
I used all default names.

I used the SqlDataAdapter wizard to get all Customers.
I also generated a typed dataset and added an instance called Dataset1

Goal: All I want to do is update the contact name. I split the first and
last name into textboxes for update and hit save.
It's not working quite right, do you see anything?

thanks in advance,
rodchar

"Cor Ligthert" wrote:
Rodchar,

Have a look for databinding and currencymanager for that (it is in the
snippet I showed you with the textbox)

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...ClassTopic.asp

That is a better approach.

I hope this helps?

Cor

"rodchar"
Here's some of my syntax:
private sub Save
m_dr.BeginEdit() 'This works
m_dr.Codes = strHold 'This works
m_dr.EndEdit() 'This does not work
End Sub

"rodchar" wrote:
Hey all,

I thought what I was doing was pretty straightforward but apparently not.
All I'm doing is loading a datarow, letting the user modify a field in
the
datarow by inputing into a textbox. I then take that textbox and assign
the
datarow field that value.

But, as soon as the assignment occurs the datarow becomes nothing. And I
have no idea why.

thanks in advance,
rodchar


Nov 21 '05 #5
ok, i got help from a different post. Each time I fill the datasource is
where the object gets lost. I'm using flags to resolve it. Thanks for the
reply.

"rodchar" wrote:
Hey Everyone,

Cor, thanks for the articles. I glanced over them and they might be a little
over my head at this time.

Can you take a look at the following code:

Dim _postBack As Boolean = False
Dim _dt As DataSet1.CustomersDataTable
Dim _dr As DataSet1.CustomersRow
Dim arrText() As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
_dt = DataSet11.Customers
ListBox1.DataSource = _dt
ListBox1.DisplayMember = "ContactName"
ListBox1.ValueMember = "CustomerID"
_postBack = True
End Sub

Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedValueChanged
If _postBack = True Then
_dr = _dt.FindByCustomerID(ListBox1.SelectedValue)
FillArray()
TextBox1.Text = arrText(0)
TextBox2.Text = arrText(1)
End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_dr.ContactName = arrText(0) & " " & arrText(1)
MessageBox.Show("Done.")
End Sub

Private Sub FillArray()
arrText = Split(_dr.ContactName, " ")
End Sub
Can you tell me if this is the way to update the contact name?
To run, using Northwind database.
All you need is 1 listbox, 2 textboxes, and a button.
I used all default names.

I used the SqlDataAdapter wizard to get all Customers.
I also generated a typed dataset and added an instance called Dataset1

Goal: All I want to do is update the contact name. I split the first and
last name into textboxes for update and hit save.
It's not working quite right, do you see anything?

thanks in advance,
rodchar

"Cor Ligthert" wrote:
Rodchar,

Have a look for databinding and currencymanager for that (it is in the
snippet I showed you with the textbox)

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...ClassTopic.asp

That is a better approach.

I hope this helps?

Cor

"rodchar"
Here's some of my syntax:
private sub Save
m_dr.BeginEdit() 'This works
m_dr.Codes = strHold 'This works
m_dr.EndEdit() 'This does not work
End Sub

"rodchar" wrote:

> Hey all,
>
> I thought what I was doing was pretty straightforward but apparently not.
> All I'm doing is loading a datarow, letting the user modify a field in
> the
> datarow by inputing into a textbox. I then take that textbox and assign
> the
> datarow field that value.
>
> But, as soon as the assignment occurs the datarow becomes nothing. And I
> have no idea why.
>
> thanks in advance,
> rodchar


Nov 21 '05 #6

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

Similar topics

2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
1
by: Yosh | last post by:
Let's say I have a DataRow that I got from DataSet "A". Can I modify the data in the DataRow and add it to a new DataSet "B" and have it update the same datasource? I hope this makes sense. ...
1
by: VMI | last post by:
Assuming I have a datarow (or a datarow collection), would it possible to create an Access table and dump the datarow(s) into that Access table? I wouldn't even need to create the fields in the...
7
by: Steve Richter | last post by:
here is a simple class: public class Demo1 : System.Data.DataRow { public Demo1() { } } but it does not compile:
2
by: Petez | last post by:
Hi, I want to declare array of System::Data::DataRow but how? With single variable I write System::Data::DataRow^ aRow but statement System::Data::DataRow^ - not works. System::Data::DataRow* ...
0
by: Doug | last post by:
I've got a strongly-typed dataset with 2 related tables in it ("Staff" and "Roles"). I want to make a change to the parent Staff row and also to its child Role row. I'm having difficulty figuring...
2
by: Carlos K | last post by:
Hello I'm having some difficulty searching a set of rows in a DataRow collection.. This is my question What would be an efficient way to search any column of an DataRow array Let me try to...
17
by: vish | last post by:
Hi all, I know this might look strange at first look, but i am looping thru a dataset created using to different tables from database.These two tables have some fields with the same names. ...
5
by: Rainer Queck | last post by:
Hello NG, what would be the best way to locate a DataRrow in a DataGridView? I have by DataTable.Select a bunch of DataRows from a DataTable (which is the data source to the DataGridView). Now...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.