473,799 Members | 3,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dataTable problem?

after update dataTable with this codes,

DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

if run under codes .it will be crush£¬

DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;

Aug 6 '06 #1
4 1552
Michael,

You need to give a better example. For example, what is the value in
"strtmp"? What is the structure of the data table? Also, what is the
exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael" <ll******@hotma il.comwrote in message
news:Ox******** ******@TK2MSFTN GP05.phx.gbl...
after update dataTable with this codes,

DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

if run under codes .it will be crush£¬

DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;

Aug 6 '06 #2
private void button1_Click(o bject sender, System.EventArg s e)
{
string delimStr = " ,.:\"?<>-+*/\\|`~!@#$%^&()' \t\n\r{}[]0123456789=;";
char [] delimiter = delimStr.ToChar Array();
string words =textBox1.Text ;

// string [] split = null;

string [] split = words.Split(del imiter);

//Èç¹ûÖ±½ÓÓÃÉÏÃæµ Ä string [] split = words.Split(del imiter);¾Í²»´æÔ Ú³¤Ê±¼äµÈ´ýµÄÎÊ ÌâÁË¡£
for(int split_i=0;split _i<split.Length ;split_i++)
{
string strtmp=split[split_i].ToLower();
if( strtmp=="") continue;

if(ff.m_dtWords .Rows.Count>0)// {
bool blaa=ff.m_dtWor ds.Rows.Contain s(strtmp);
if(blaa==true)//
{
DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;

int cxpl=Convert.To Int32(foundRow. ItemArray[2].ToString())+1;

//int ii=Convert.ToIn t32(ff.m_dtWord s.Rows[i]["id"]);
save(strtmp,m_i d,cxpl);

goto loop;

}
else
{
save(strtmp,-1,1);
}
}
else
{

save(strtmp,-1,1);

}//end if

loop:;

}//end for

showMdb();
//datagrid refresh
dataSet11.Clear ();
ff.m_daDataAdap ter.Fill(dataSe t11,"rj");
dataGrid1.DataS ource=dataSet11 ;
dataGrid1.SetDa taBinding(dataS et11.Tables[0].DataSet
,dataSet11.Tabl es[0].TableName);
}
public void save(string str,int m_id,int pinlu)
{
if(pinlu==1)//==1 new record
{
//
try
{
DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

}
catch
{
}
}
else
{
try
{
ff.m_dtWords.Ro ws [m_id]["frequency"]=frequency;

//label3.Text="ha ve same words";
ff.m_daDataAdap ter.Update(ff.m _dtWords);
return;
}
catch
{
textBox1.Text+= str+" "+frequency+"\r \n";
}

}

}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omдÈëÏûÏ¢ÐÂÎÅ: ez************* *@TK2MSFTNGP03. phx.gbl...
Michael,

You need to give a better example. For example, what is the value in
"strtmp"? What is the structure of the data table? Also, what is the
exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael" <ll******@hotma il.comwrote in message
news:Ox******** ******@TK2MSFTN GP05.phx.gbl...
>after update dataTable with this codes,

DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

if run under codes .it will be crush£¬

DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;


Aug 7 '06 #3
Michael,

Have you tried to see the value you are passing to ToInt32? Most
likely, you are passing something that is not a number.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael" <ll******@hotma il.comwrote in message
news:e9******** ********@TK2MSF TNGP04.phx.gbl. ..
private void button1_Click(o bject sender, System.EventArg s e)
{
string delimStr = " ,.:\"?<>-+*/\\|`~!@#$%^&()' \t\n\r{}[]0123456789=;";
char [] delimiter = delimStr.ToChar Array();
string words =textBox1.Text ;

// string [] split = null;

string [] split = words.Split(del imiter);

//Èç¹ûÖ±½ÓÓÃÉÏÃæµ Ä string [] split =
words.Split(del imiter);¾Í²»´æÔ Ú³¤Ê±¼äµÈ´ýµÄÎÊ ÌâÁË¡£
for(int split_i=0;split _i<split.Length ;split_i++)
{
string strtmp=split[split_i].ToLower();
if( strtmp=="") continue;

if(ff.m_dtWords .Rows.Count>0)// {
bool blaa=ff.m_dtWor ds.Rows.Contain s(strtmp);
if(blaa==true)//
{
DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;

int cxpl=Convert.To Int32(foundRow. ItemArray[2].ToString())+1;

//int ii=Convert.ToIn t32(ff.m_dtWord s.Rows[i]["id"]);
save(strtmp,m_i d,cxpl);

goto loop;

}
else
{
save(strtmp,-1,1);
}
}
else
{

save(strtmp,-1,1);

}//end if

loop:;

}//end for

showMdb();
//datagrid refresh
dataSet11.Clear ();
ff.m_daDataAdap ter.Fill(dataSe t11,"rj");
dataGrid1.DataS ource=dataSet11 ;
dataGrid1.SetDa taBinding(dataS et11.Tables[0].DataSet
,dataSet11.Tabl es[0].TableName);
}
public void save(string str,int m_id,int pinlu)
{
if(pinlu==1)//==1 new record
{
//
try
{
DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

}
catch
{
}
}
else
{
try
{
ff.m_dtWords.Ro ws [m_id]["frequency"]=frequency;

//label3.Text="ha ve same words";
ff.m_daDataAdap ter.Update(ff.m _dtWords);
return;
}
catch
{
textBox1.Text+= str+" "+frequency+"\r \n";
}

}

}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om>
дÈëÏûÏ¢ÐÂÎÅ:ez **************@ TK2MSFTNGP03.ph x.gbl...
>Michael,

You need to give a better example. For example, what is the value in
"strtmp"? What is the structure of the data table? Also, what is the
exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael" <ll******@hotma il.comwrote in message
news:Ox******* *******@TK2MSFT NGP05.phx.gbl.. .
>>after update dataTable with this codes,

DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

if run under codes .it will be crush£¬

DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;



Aug 7 '06 #4
Nicholas Paldino:

thanks,

i think i have found the wrong code,
i add the code in the save():

drNewRow["id"]=ff.m_dtWords.R ows.Count+1 ;

it be OK now;

but I don't know why "id" is a field that be auto added in the structure of
the data table in the MS access ,
in the c# ,it must forced be assign a value?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omдÈëÏûÏ¢ÐÂÎÅ: eO************* *@TK2MSFTNGP03. phx.gbl...
Michael,

Have you tried to see the value you are passing to ToInt32? Most
likely, you are passing something that is not a number.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael" <ll******@hotma il.comwrote in message
news:e9******** ********@TK2MSF TNGP04.phx.gbl. ..
> private void button1_Click(o bject sender, System.EventArg s e)
{
string delimStr = " ,.:\"?<>-+*/\\|`~!@#$%^&()' \t\n\r{}[]0123456789=;";
char [] delimiter = delimStr.ToChar Array();
string words =textBox1.Text ;

// string [] split = null;

string [] split = words.Split(del imiter);

//Èç¹ûÖ±½ÓÓÃÉÏÃæµ Ä string [] split = words.Split(del imiter);¾Í²»´æÔ Ú³¤Ê±¼äµÈ´ýµÄÎÊ ÌâÁË¡£
for(int split_i=0;split _i<split.Length ;split_i++)
{
string strtmp=split[split_i].ToLower();
if( strtmp=="") continue;

if(ff.m_dtWords .Rows.Count>0)// {
bool blaa=ff.m_dtWor ds.Rows.Contain s(strtmp);
if(blaa==true)//
{
DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;

int cxpl=Convert.To Int32(foundRow. ItemArray[2].ToString())+1;

//int ii=Convert.ToIn t32(ff.m_dtWord s.Rows[i]["id"]);
save(strtmp,m_i d,cxpl);

goto loop;

}
else
{
save(strtmp,-1,1);
}
}
else
{

save(strtmp,-1,1);

}//end if

loop:;

}//end for

showMdb();
//datagrid refresh
dataSet11.Clear ();
ff.m_daDataAdap ter.Fill(dataSe t11,"rj");
dataGrid1.DataS ource=dataSet11 ;
dataGrid1.SetDa taBinding(dataS et11.Tables[0].DataSet
,dataSet11.Tab les[0].TableName);
}
public void save(string str,int m_id,int pinlu)
{
if(pinlu==1)//==1 new record
{
//
try
{
DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

}
catch
{
}
}
else
{
try
{
ff.m_dtWords.Ro ws [m_id]["frequency"]=frequency;

//label3.Text="ha ve same words";
ff.m_daDataAdap ter.Update(ff.m _dtWords);
return;
}
catch
{
textBox1.Text+= str+" "+frequency+"\r \n";
}

}

}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omдÈëÏûÏ¢ÐÂÎÅ: ez************* *@TK2MSFTNGP03. phx.gbl...
>>Michael,

You need to give a better example. For example, what is the value in
"strtmp"? What is the structure of the data table? Also, what is the
exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael" <ll******@hotma il.comwrote in message
news:Ox****** ********@TK2MSF TNGP05.phx.gbl. ..
after update dataTable with this codes,

DataRow drNewRow = ff.m_dtWords.Ne wRow();

drNewRow["words"]=str;

drNewRow["frequency"]=frequency;

ff.m_dtWords.Ro ws.Add(drNewRow );
ff.m_daDataAdap ter.Update(ff.m _dtWords);

if run under codes .it will be crush£¬

DataRow foundRow;

foundRow =ff.m_dtWords.R ows.Find(strtmp );

int m_id=Convert.To Int32(foundRow. ItemArray[0].ToString())-1;





Aug 7 '06 #5

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

Similar topics

0
3191
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some text. Before changing to another cell in the DataGrid, I move my mouse pointer off the DataGrid and change the selected item in a ListBox or TreeView. Here's my question Which should fire first, the DataTable's RowChanged/CellChanged event or...
5
10092
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma table is each of them isn't on a stirng, but right no I have to do it in a wat of: 1. passing DataTable to method (lets call it SelectOverDataTabel) 2. declare a local (in SelectOver...) DataTable, inicialize it with my value
4
2577
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the contents on certain fields. The grouping/filtering is "remembered" for each user via a cookie. The problem is works like this: User A applies a filter on Project Manager. User B filters by Department. User B groups by Project Manager (NOTE -...
1
2974
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
3
8091
by: Frans Bouma | last post by:
Hi, I have a serious problem with VB.NET and a DataTable derived class and I can't figure out how to solve it. I have implemented it in C# where it works perfectly, but I can't port one statement to VB.NET and this is crucial: re-implementing ISerializable.GetObjectData() in the DataTable derived class so serializing the datatable derived class will call this method and not the DataTable version (which is private, so overriding is also...
12
2288
by: Doug Bell | last post by:
Hi, I am having problems trying to create a (temporary) DataTable from a selection from a DataGrid (dgOrders). dtOrdDetails is declared as a Public DataTable Sub is: Dim stFilter as String Dim OrdersRows() as DataRow
10
4956
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
9
4029
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
5
8640
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
9
6993
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table population. Whenever I call the thread, I pass it a structure containing the table and a few other parameters. The table goes in as a reference, but the other items are passed normally.
0
9687
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
10488
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
10257
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
10237
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
9077
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...
0
6808
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();...
0
5467
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...
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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.