473,779 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1407
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.Custom ersDataTable
Dim _dr As DataSet1.Custom ersRow
Dim arrText() As String
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
SqlDataAdapter1 .Fill(DataSet11 )
_dt = DataSet11.Custo mers
ListBox1.DataSo urce = _dt
ListBox1.Displa yMember = "ContactNam e"
ListBox1.ValueM ember = "CustomerID "
_postBack = True
End Sub

Private Sub ListBox1_Select edValueChanged( ByVal sender As Object, ByVal
e As System.EventArg s) Handles ListBox1.Select edValueChanged
If _postBack = True Then
_dr = _dt.FindByCusto merID(ListBox1. SelectedValue)
FillArray()
TextBox1.Text = arrText(0)
TextBox2.Text = arrText(1)
End If

End Sub

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

Private Sub FillArray()
arrText = Split(_dr.Conta ctName, " ")
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.Custom ersDataTable
Dim _dr As DataSet1.Custom ersRow
Dim arrText() As String
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
SqlDataAdapter1 .Fill(DataSet11 )
_dt = DataSet11.Custo mers
ListBox1.DataSo urce = _dt
ListBox1.Displa yMember = "ContactNam e"
ListBox1.ValueM ember = "CustomerID "
_postBack = True
End Sub

Private Sub ListBox1_Select edValueChanged( ByVal sender As Object, ByVal
e As System.EventArg s) Handles ListBox1.Select edValueChanged
If _postBack = True Then
_dr = _dt.FindByCusto merID(ListBox1. SelectedValue)
FillArray()
TextBox1.Text = arrText(0)
TextBox2.Text = arrText(1)
End If

End Sub

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

Private Sub FillArray()
arrText = Split(_dr.Conta ctName, " ")
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
3603
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 can't figure out why the design is so that the DataRow "alters" the value entered. In my application a decimal column in a row of a specific table has a fix number of decimal places according to certain premises. The
1
1402
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. Yosh sorry for the multiple post but I wanted the post in this newsgroup
1
5926
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 Access table since the datarow contains the exact table schema. I'm currently taking each datarow and creating an Insert statement that i then run against Access. I posted this question earlier and someone suggested "configure an OleDbDataAdapter...
7
5767
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
3311
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* - not works. System::Data::DataRow^^ - not works. I need this array for store result of DataTable->Rows->Select(...) Thanks, Peter
0
1393
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 out the best way to do this. First question: I can get myself a new instance of a row and make changes to it, but presumably that's then a separate object from the original dataset row. How do I reconcile my changes back to the dataset?
2
1645
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 explain the context of this question, that will help you understand what I'm looking for.. Assume that I have a collection of rows that came out of a statement like this dim myRows() as DataRow = myTable.Select("any query"
17
7646
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. Now i want to use those columns from datarow. How can i get exactly the same column i want not the othere duplicate one residing in the datarow?
5
39680
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 I would like to give those related DataGridViewRows a different BackColor. Thanks for hints and help! Rainer
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.