473,666 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strongly typed data - the 'current row'

I've got a Windows Forms app talking to an Access db, and I'm
experimenting with VS2005's form data binding stuff etc.

I've got a dataset, a datagridview bound to a query (let's call it
Customers), and I have a button called Edit, which when clicked should
spawn a dialog wherein the customer associated with the current row in
the grid should be edited.

So I need to pass the 'current' Customer ID to this form. There's an
topic in the help titled "Walkthroug h: Passing Data Between Forms in a
Windows Application" wherein a similar thing happens: to quote,

"Using the customers and orders tables from Northwind one form will
allow users to select a customer and a second form will display the
selected customer's orders. This walkthrough shows how to create a
method on one form that receives data from the first form."

The relevant part of the walkthrough is this:

Private Sub CustomersDataGr idView_DoubleCl ick(ByVal sender As Object,
ByVal e As System.EventArg s) _
Handles CustomersDataGr idView.DoubleCl ick

Dim SelectedRowView As Data.DataRowVie w
Dim SelectedRow As NorthwindDataSe t.CustomersRow

SelectedRowView = CType(Customers BindingSource.C urrent,
System.Data.Dat aRowView)
SelectedRow = CType(SelectedR owView.Row,
NorthwindDataSe t.CustomersRow)

Dim OrdersForm As New Form2
OrdersForm.Load Orders(Selected Row.CustomerID)
OrdersForm.Show ()
End Sub

My question is - what's with all these CTypes? I've (or rather, the IDE
has) gone to all this trouble to make a whole bundle of strongly-typed
types for my dataset, my datatables, my tableadapters, my columns, my
rows, change events etc etc (the xsd file is enormous when you look at
it in code!) - and yet just to say 'the current value of column X for
data object Y' I have to do 2 CTypes?

Surely there's a cleaner way of just saying 'the current customer ID' ?

--
Larry Lard
Replies to group please

Feb 10 '06 #1
1 1548
CMM
Bind the CustomerId to a control on the form (hidden or otherwise) and pick
it up from that and bypass having to use the navigator objects to get it.

OrdersForm.Load Orders(Me.Custo merIDLabel)

--
-C. Moya
www.cmoya.com
Feb 10 '06 #2

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

Similar topics

0
5851
by: Uchiha Jax | last post by:
I have used this method many a time in previous applications without any hitches at all and i'm trying to use it in my current application and it isn't working. The only difference I can see is that I am using a strongly typed dataset (and hence datatables and datarows), does that make this function not work? I figured as my TaskRow inherited from DataRow that there shouldn't be a problem. The code, put simply is as follows:
0
2006
by: Uchiha Jax | last post by:
When using a strongly typed dataset (generated from the Visual Studio IDE from an XSD file) and databinding I get a really odd error when binding to both a combox and a datetimepicker. I bind like the following: //// tDs is the strongly typed dataset, //// tDs.TheTask returns a strongly typed row from one of the tables. /// GetBindingTaskTypes() returns the types I want to use as a datasource in an arraylist.
1
2179
by: HardBap | last post by:
I've created a strongly typed DataSet (Customers.xsd) using the xsd.exe tool. I want to be able to access fields using ds.Customer.CompanyName. The problem is when I return this DataSet from a Web Service it adds another Table to the DataSet that contains the data. I have to access the data using ds.Tables.Rows.ToString(). This defeats the whole purpose of using a strongly typed DataSet. Thanks in advance for the help.
1
2255
by: Ersin Gençtürk | last post by:
I have 2 typed data tables inherited from the same dataset schema One called : table A with an identity column x column x is constrained to be unique. Other one is : table B with an identity column x There are some rows in table A and table B. When I want to add a row from table A to table B I use the function TableA.ImportRow(TableB.rows); // for example
1
1897
by: PeterH | last post by:
I am developing a web service in VB.Net that returns data from a server. I have an .asmx page that uses a strongly typed dataset and I would like to return data in the form of strongly typed data table rows. However I always get an error message to do with the fact that the data set is not serializable. For example: "You must implement the Add(System.Object) method on xyz data table because it inherits from IEnumerable." The strongly...
0
1823
by: Scott_from_Carematic | last post by:
I'm trying to use a strongly typed dataset in my asp.net (2.0) project with visual studio 2005. I have generated the dataset and tableadapters in the designer. I'm using SQL server EE 2005 as the database. One of my tables has a guid field that has the "allow NULL" property in the database. If I create a <typed>datatable, then try to add a row to the new table, passing the value DBNULL.value as the field value in question, then I get...
4
2517
by: Ted Ngo | last post by:
I create a northwind Strongly Typed TableAdapters dataset, the create a query like "select a, b, c, d from employeetable" then bind it into the gridview dim t as new northwindTableAdapters gridview1.datasource = t.getdata() gridview1.databind() Now I create new query in the TableAdapters dataset
1
3559
by: Code Monkey | last post by:
Silly question maybe, but I've been doing the following for far too long now: public static DataTable myDataTable() { string sql = @"SELECT column1, column2, column3, column4 FROM myTable"; using (SqlConnection conn = new SqlConnection(websqlconn)) { SqlCommand cmd = new SqlCommand(sql, conn);
4
3105
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their comparisions) cleared? Thanks, Rachana
0
8356
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
8866
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...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
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...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
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
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
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
2011
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.