473,386 Members | 1,699 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,386 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 1381
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.