|
hi
i have a table in my dataset and i create another datatable as "dt",i want to copy a few rows from myDataset.Tables[0] to dt but the following error shown me :
This row already belongs to another table.
how to solve my problem ?
My code is :
foreach (DataGridViewRow _gridViewRow in dataGridView1.Rows)
{
if (_gridViewRow.Cells[0].Value != null)
{
if (_gridViewRow.Cells[0].Value.ToString() == "True")
{
//_gridViewRow.Visible = true;
//c++;
DataRow row = ds_zamin1.Khaneh_1.Rows[_gridViewRow.Index];
ds_zamin1.Khaneh_1.Rows.Remove(row);
dt.Rows.Add(row); //error in this line }
}
}
this.dataGridView2.DataSource = dt;
|
|
|
|
|
Use DataTable.ImportRow() instead.
Regards
|
|
|
|
|
hi
thanks .. it is works, but a Bigger Problem :
when i set Datagridview2.Datasource to dt, nothing occured and imported rows does not appear in datagridview2, how to solve this problem ?
My Code Is :
DataTable dt = new DataTable();
foreach (DataGridViewRow _gridViewRow in dataGridView1.Rows)
{
if (_gridViewRow.Cells[0].Value != null)
{
if (_gridViewRow.Cells[0].Value.ToString() == "True")
{
DataRow row = ds_zamin1.Khaneh_1.Rows[_gridViewRow.Index];
dt.ImportRow(row);
}
}
}
this.dataGridView1.DataSource = dt; // Nothing Occured
|
|
|
|
|
First allow me to put a small touch on your code -Don't forget to add the pre tags next time please;)-
DataTable dt = new DataTable();
foreach (DataGridViewRow _gridViewRow in dataGridView1.Rows)
{
if (_gridViewRow.Cells[0].Value != null && _gridViewRow.Cells[0].Value.ToString() == "True")
dt.ImportRow(ds_zamin1.Khaneh_1.Rows[_gridViewRow.Index]);
}
this.dataGridView1.DataSource = dt;
If dt is a local variable, then it'll be destroyed after the current method is finished which for sure wil simply make nothing.
Regards
|
|
|
|
|
first:clone the dataset.table[0] to dt,
seconde is your code.ok
Maybe
|
|
|
|
|
Hi!
I need to load a DataGridViewComboBoxCell from dynamic SQL data and the other DataGridViewTextBoxCell from another SQL datasource.
Thats not it... i need also be able to edit one single value from it.
For exmple, I need to be able to select some item or insted be able to insert a new value to get from some insert qerry. All this for earch row in a normal DataGridView Component from Visual Studio .Net 2005
tnks!
___________________________
vykom's best.
Free your mind! use GPL.
up to open source!!!
|
|
|
|
|
If you need to populate a DataGridView from multiple sources, you can do that using DataBindingSource with no problem. You can either specify a data member for each column manually, or I'd go for making a DataView with the custom view you want to make using a SQL SELECT statement.
About your second question, I don't really understand what you want to do. Maybe you could give an example or be more specific?
Regards
|
|
|
|
|
well, tnks for that.
About the second question, what I need is something like this:
Some user, can manually select an item loaded in the DataGridViewComboBoxCell, but, in any case, he can manually insert a value typing it too.
That's why I can't explicity load all items from a BindingSource or TableAdapter normally, because I wouldn't add or edit any item from the control.
Y try getting the full action over "mouseclicked" and "itemselected", but I couln't add an item in the combo .... exception released because i'm trying to edit all the concurrency of the BindingSource. And also loading the commbo manually, I couln't draw a simple TextBox in the place of the ComoboBoxCell..
It's kind of tricky.
(sorry my english)
___________________________
vykom's best.
Free your mind! use GPL.
up to open source!!!
|
|
|
|
|
I guess you'd have to do it manually.
You'd check if the value written in the combobox is available in your datasource. If not add it directly in the datasource using a SQL Statement.
Did I get you right this time, or am I still astray?
Regards
|
|
|
|
|
Right in the correct spot !!!!!!
Tanks a lot. I've make it work thanks to you!
see you around ????
___________________________
vykom's best.
Free your mind! use GPL.
up to open source!!!
|
|
|
|
|
can i make a pointer in console by c#, like in this program which reads an integer K and prints the list of clients of lawyer K. for each K (consists 4 alphabetized lists of clients and their respective lawyer ). or we must make it in c++
thx a lot
LAWyer Point
1 Davis 4
2 Levine 12
3 Nelson 21
4 Rogers 8
Client age link
1 hall 35 16
2 moss 28 13
3 ford 47 25
4 brown 54 22
5 ginn 38 14
6 pride 42 29
7
8 berk 38 3
9 white 45 0
10
11 todd 25 0
12 dixon 32 24
13 new 46 6
14 har 42 30
15 AVAIL 15
16 jack 52 27
17
18 robert 40 0
19
20 eisen 32 1
21 adams 48 5
22 coh 36 20
23
24 fis 33 18
25 gra 42 11
26
27 parker 50 9
28
29 singer 45 0
30 lew 28 2
-- modified at 16:22 Thursday 23rd November, 2006
|
|
|
|
|
Could you clearify the question? I don't really understand what you want to do, and certainly not how it has anything at all to do with pointers.
---
b { font-weight: normal; }
|
|
|
|
|
amirafouad21 wrote: integer K and prints the list of clients of lawyer K
Wait a minute?!! K is an integer or a lawyer?!!
amirafouad21 wrote: prints the list of clients of lawyer K. for each K
Am I smelling Database in here? If you want to manipulate data go for SQL, and yes you can do that in C#.
Regards
|
|
|
|
|
i don't understand u will but if u want to use pointer u can use it using unsafe code
|
|
|
|
|
I`m using System.IO.DriveInfo.GetDrives() funcd tion to get DriveInfo anextract information about drives but it works really bad with SATA disks (gives me errors)?
Does anybody have solution for this?
|
|
|
|
|
Vertyg0 wrote: but it works really bad with SATA disks (gives me errors)
What are the errors you get exactly? Also a code snippet would be very helpful.
Regards
|
|
|
|
|
DriveInfo[] drivesInfo = DriveInfo.GetDrives();
foreach (DriveInfo drive in drivesInfo)
listBox1.Items.Add(drive.Name + " " + drive.VolumeLabel);
************** Exception Text **************
System.IO.IOException: The device is not ready.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIODriveError(String driveName, Int32 errorCode)
at System.IO.DriveInfo.get_VolumeLabel()
at SqlServerMonitor.AddDisk.AddDisk_Load(Object sender, EventArgs e) in C:\...\AddDisk.cs:line 23
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
I would put the listBox1.Items.Add... in a try/catch , because you probably are asking your DVD-drive to tell you the VolumeLabel and if there is no DVD in it you will get an exception.
|
|
|
|
|
Hello Everyone
I was trying to write the algorithm that finds the anagram of words randomaly
for example hello
so far this is what i have
public void findAnagram(String prefix, String suffix)
{
String newPrefix, newSuffix;
if (suffix.Length == 1)
{
Console.WriteLine(prefix + suffix);
}
else
{
for (int i = 0; i < suffix.Length; i++)
{
newSuffix = suffix.Substring(1, suffix.Length);
newPrefix = prefix + suffix[0];
findAnagram(newPrefix, newSuffix);
suffix = newSuffix + suffix[0];
}
}
}
but for some reason it throws me a exception when i put it in main method
"Index and length must refer to a location within the string."
i am wondering if there is a better way to find a anagram of any word
thank you
|
|
|
|
|
homer simpsom wrote: suffix.Length
As you're starting at 1, and it's 0 indexed, the Length property goes one character past the end.
Christian Graus - C++ MVP
|
|
|
|
|
Hi Friends
I m using sqlhelper class file which is stored in DataAccessLayer,it is used for connecting the data from database.
But when i m using this sqlhelper in another class getting an error.
In visual studio 2003,the code is
SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Projectname.Global.CfgKeyConnString]
, "SPName", parameters);
but same code in 2005, getting an error.
so could any one give an idea to solve this problem.
Thanking U,
Naren.
|
|
|
|
|
Is it possible to serialize an Image?
I have a class that containes an Image loaded from a jpeg, when I tried to serialize it I couldn't.
any help would be appreciated
|
|
|
|
|
Hi
I would like to see the query log from sqlserver 2000, but i cannot. How can i do that?
|
|
|
|
|
hi
i want to set myDatagridView.Rows[i].Visible = false; but the Following error has shown me :
Row associated with the currency manager's position cannot be made invisible
How to solve problem and hide each Row that i select at runtime without this error ?
My Code is :
int i = 0;
while (i < this.dataGridView1.Rows.Count)
{
DataGridViewRow GridViewrow = this.dataGridView1.Rows[i];
if (GridViewrow.Cells[0].ToString() == "True")
{
}
else
GridViewrow.Visible = false; //error in this line
i++;
}
|
|
|
|
|
Well I'm not totally sure, but I can tell you're having a BindingSource problem.
In my expirience, I wouldn't be able to edit almost nothing usingn BingdingSource or TableAdapters, because we can not mess with the internal managment of the .NetFramework.
Solution: Fill the DataGridView manually using sql querry, it should solve the problem.. (I mean manually exactly how it sounds.. row by row and Cell by Cell)
good luck.
(sorry my english)
___________________________
vykom's best.
Free your mind! use GPL.
up to open source!!!
|
|
|
|