473,695 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# express addition DataRow related warning

While experimenting with binding datasets to an MS DataGridView, I get
a warning that tells me that my DataRows are "either undeclared or was
never assigned". Assuming that I am reading the documentation
correctly, you are supposed to create a DataRow using the
"DataTable.NewR ow()" method. This is what I do in my app. As a matter
of fact, the DataRow constructor appears to be protected so I can't
directly create it if I want to. Is this warning a bug in MS C#
express? Or am I doing something wrong? If I ignore the warning and
run the app, it works as expected. Just trying to sort out the best
way to remove this warning.

-Michael

Jan 3 '06 #1
3 1810
Michael,

Can you post the code? This error has little to do with the actual way
you create the data row, but rather, a variable that is not assigned
properly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"mi************ @hotmail.com" <ge******@gmail .com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
While experimenting with binding datasets to an MS DataGridView, I get
a warning that tells me that my DataRows are "either undeclared or was
never assigned". Assuming that I am reading the documentation
correctly, you are supposed to create a DataRow using the
"DataTable.NewR ow()" method. This is what I do in my app. As a matter
of fact, the DataRow constructor appears to be protected so I can't
directly create it if I want to. Is this warning a bug in MS C#
express? Or am I doing something wrong? If I ignore the warning and
run the app, it works as expected. Just trying to sort out the best
way to remove this warning.

-Michael

Jan 3 '06 #2
mi************@ hotmail.com wrote:
While experimenting with binding datasets to an MS DataGridView, I get
a warning that tells me that my DataRows are "either undeclared or was
never assigned". Assuming that I am reading the documentation
correctly, you are supposed to create a DataRow using the
"DataTable.NewR ow()" method. This is what I do in my app. As a matter
of fact, the DataRow constructor appears to be protected so I can't
directly create it if I want to. Is this warning a bug in MS C#
express? Or am I doing something wrong? If I ignore the warning and
run the app, it works as expected. Just trying to sort out the best
way to remove this warning.

-Michael

You create a row by doing:

DataRow dr = dtDataTable.New Row();

Nut after that you need to add that row to the table:

dtDataTable.Row s.Add(dr);

....because beleive it or not, the row created by NewRow doesn't belong to the table by default.

Hope it helps,
MuZZy
Jan 4 '06 #3
Here is the code. I know that it isn't good practice to put data
related code directly together with GUI code. This was just a simple
test to familiarize myself with the MS data related classes; search for
the string "DataRow dr = d.NewRow();" to jump to relavent section of
the code; I think I'm doing things by the book as per MS documentation,
but perhaps I'm missing something such that I'm getting the warning in
C# Express Edition; note that the code compiles and runs fine...
----------------------------------------------

using System.Data;

namespace Test
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.d = new System.Data.Dat aTable();
this.ds = new System.Data.Dat aSet();
this.dataGridVi ew1 = new
System.Windows. Forms.DataGridV iew();
this.button1 = new System.Windows. Forms.Button();
this.clientIDDa taGridViewTextB oxColumn = new
System.Windows. Forms.DataGridV iewTextBoxColum n();
this.clientName DataGridViewTex tBoxColumn = new
System.Windows. Forms.DataGridV iewTextBoxColum n();

((System.Compon entModel.ISuppo rtInitialize)(t his.d)).BeginIn it();

((System.Compon entModel.ISuppo rtInitialize)(t his.ds)).BeginI nit();

((System.Compon entModel.ISuppo rtInitialize)(t his.dataGridVie w1)).BeginInit( );
this.SuspendLay out();
//
// d
//
this.d.TableNam e = "Client";
//
// ds
//
this.ds.DataSet Name = "ClientDB";
this.ds.Tables. AddRange(new System.Data.Dat aTable[] {
this.d});

d.Columns.Add(" ClientID",
System.Type.Get Type("System.In t32"));
d.Columns.Add(" ClientName",
System.Type.Get Type("System.St ring"));

DataRow dr = d.NewRow();
dr["ClientID"] = 2;
dr["ClientName "] = "Fidelity";
d.Rows.Add(dr);

//
// dataGridView1
//
this.dataGridVi ew1.AllowUserTo OrderColumns = true;
this.dataGridVi ew1.AutoGenerat eColumns = false;
this.dataGridVi ew1.ColumnHeade rsHeightSizeMod e =
System.Windows. Forms.DataGridV iewColumnHeader sHeightSizeMode .AutoSize;
this.dataGridVi ew1.Columns.Add Range(new
System.Windows. Forms.DataGridV iewColumn[] {
this.clientIDDa taGridViewTextB oxColumn,
this.clientName DataGridViewTex tBoxColumn});
this.dataGridVi ew1.DataMember = "Client";
this.dataGridVi ew1.DataSource = this.ds;
this.dataGridVi ew1.Location = new System.Drawing. Point(139,
69);
this.dataGridVi ew1.Name = "dataGridView1" ;
this.dataGridVi ew1.Size = new System.Drawing. Size(240,
150);
this.dataGridVi ew1.TabIndex = 0;
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(457, 71);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(154, 72);
this.button1.Ta bIndex = 1;
this.button1.Te xt = "button1";
this.button1.Us eVisualStyleBac kColor = true;
this.button1.Cl ick += new
System.EventHan dler(this.butto n1_Click);
//
// clientIDDataGri dViewTextBoxCol umn
//
this.clientIDDa taGridViewTextB oxColumn.DataPr opertyName =
"ClientID";
this.clientIDDa taGridViewTextB oxColumn.Header Text =
"ClientID";
this.clientIDDa taGridViewTextB oxColumn.Name =
"clientIDDataGr idViewTextBoxCo lumn";
//
// clientNameDataG ridViewTextBoxC olumn
//
this.clientName DataGridViewTex tBoxColumn.Data PropertyName =
"ClientName ";
this.clientName DataGridViewTex tBoxColumn.Head erText =
"ClientName ";
this.clientName DataGridViewTex tBoxColumn.Name =
"clientNameData GridViewTextBox Column";
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(834, 663);
this.Controls.A dd(this.button1 );
this.Controls.A dd(this.dataGri dView1);
this.Name = "Form1";
this.Text = "Form1";

((System.Compon entModel.ISuppo rtInitialize)(t his.d)).EndInit ();

((System.Compon entModel.ISuppo rtInitialize)(t his.ds)).EndIni t();

((System.Compon entModel.ISuppo rtInitialize)(t his.dataGridVie w1)).EndInit();
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.DataGridV iew dataGridView1;
private System.Windows. Forms.Button button1;
private System.Data.Dat aTable d;
private System.Data.Dat aSet ds;
private System.Windows. Forms.DataGridV iewTextBoxColum n
clientIDDataGri dViewTextBoxCol umn;
private System.Windows. Forms.DataGridV iewTextBoxColum n
clientNameDataG ridViewTextBoxC olumn;
}
}

Jan 4 '06 #4

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

Similar topics

1
1858
by: MLH | last post by:
I'm trying to overcome the pop-up warning issued by Outlook Express when an Access application uses SendObject to mail an attachment (report object converted to an rtf file) to a specified recipient. I regret to give up all the security features of Q330994, but it seems that I have no choice. Like pork barrel politics, there are things I want and things I don't want in the patch. Any past experiences - please share them. Here are some...
1
1870
by: Marcel Sottnik | last post by:
Hello group Maybe this is not the right NG, but this problem seems to me to be more language related than ADO.NET. How can I write the constructor for specialization of DataRow which will take a datarow as parameter. Something like: class MyDataRow : DataRow {
2
4892
by: siedem | last post by:
Hi I have to write a plugin to MS Outlook Express and MSN Messenger. Does anybody have any examples or documentation related with this topic? thanks in advance P.
3
7964
by: sgottenyc | last post by:
Hello, Has anyone had any success running SQL Server Express on Vista with Apache via PHP? My PHP works fine, Apache works fine, and SQL Server Express works fine in Management Studio, but I cannot connect via this call: $myServer = "servername"; $myUser = "username"; $myPass = "password"; $myDB = "myDB";
0
8639
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
9120
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
8999
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...
1
8858
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
8832
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
5841
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
3016
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
2279
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1980
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.