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;