table wont update fields

hello here, i have one problem, here is code first

[code]public void SaveToDb(HttpServerUtility Server, int JezikID)
{
OleDbConnection conn = new OleDbConnection(new Util(Server).ConnectionString);
conn.Open();

//save text

OleDbCommand cmd = new OleDbCommand("Insert into Tekst (JezikID, Tekst, tekst_rijeci, tekst_znak) values (@JezikID, @Tekst, @tekst_rijeci, @tekst_znak)", conn);
cmd.Parameters.Add(new OleDbParameter("@JezikID", JezikID));
cmd.Parameters.Add(new OleDbParameter("@Tekst", m_Text));
cmd.Parameters.Add(new OleDbParameter("@tekst_rijeci", BrojRijeci));
cmd.Parameters.Add(new OleDbParameter("@tekst_znak", BrojZnakova));
cmd.ExecuteNonQuery();
cmd.Dispose();

// Save letters of bigram

foreach(Ngram ngram in m_bigramCharList)
{
cmd = new OleDbCommand("select ID from BigramChar where bigram = @bigram", conn);
cmd.Parameters.Add(new OleDbParameter("@bigram", ngram.Znakovi));
cmd.Parameters.Add(new OleDbParameter("@bigram_broj", ngram.Count));
object NgramID = cmd.ExecuteScalar();
cmd.Dispose();

// if there is no ngram, insert, or if it is ngram, update...

if (NgramID != null)
{
int iNgramID = (int)NgramID;
cmd = new OleDbCommand("UPDATE BigramChar SET bigram_broj = bigram_broj + @bigram_broj, bigram_txt = bigram_txt + @bigram_txt WHERE ID = @ID", conn);
cmd.Parameters.Add(new OleDbParameter("@ID", NgramID));
cmd.Parameters.Add(new OleDbParameter("@JezikID", JezikID));
cmd.Parameters.Add(new OleDbParameter("@bigram_broj", ngram.Count));
cmd.Parameters.Add(new OleDbParameter("@bigram_txt", BrojZnakova));
cmd.ExecuteNonQuery();
cmd.Dispose();

}
else
{
cmd = new OleDbCommand("insert into BigramChar (JezikID, bigram, bigram_broj, bigram_txt) values (@JezikID, @bigram, @bigram_broj, @bigram_txt)", conn);
cmd.Parameters.Add(new OleDbParameter("@JezikID", JezikID));
cmd.Parameters.Add(new OleDbParameter("@bigram", ngram.Znakovi));
cmd.Parameters.Add(new OleDbParameter("@bigram_broj", ngram.Count));
cmd.Parameters.Add(new OleDbParameter("@bigram_txt", BrojZnakova));
cmd.ExecuteNonQuery();
cmd.Dispose();
}
}[/code]

so table wont update fields, i tried this

here is my table with bigrams

[b]ID JezikID bigram bigram_broj bigram_txt
922 5 ja 1 6
923 5 a 1 6
924 5 t 1 6
925 5 ti 1 6
926 5 i 1 6
927 5 o 1 6
928 5 on 1 6[/b]



[code]foreach(Ngram ngram in m_bigramCharList)
{
cmd = new OleDbCommand("select ID from BigramChar where bigram = @bigram", conn);
cmd.Parameters.Add(new OleDbParameter("@bigram", ngram.Znakovi));
object NgramID = cmd.ExecuteScalar();
cmd.Dispose();
...

if (NgramID != null)
{
int iNgramID = (int)NgramID;

[b]cmd = new OleDbCommand("insert into tbl_ID (charID) VALUES (@ID)", conn);[/b]
cmd.Parameters.Add(new OleDbParameter("@ID", iNgramID));
...[/code]

i have this in new table with ID of each bigram

[b]ID charID
590 922 - ID of ja
591 923 - ID of a
592 924 - ...
593 925
594 926
595 927
596 928[/b]

so he found ID and he still does not want to update, if i try to do it like this and after i change the code and use exact numbers for [b]@bigram_txt[/b] and [b]@bigram_broj[/b]

[code]foreach(Ngram ngram in m_bigramCharList)
{
cmd = new OleDbCommand("select ID from BigramChar where bigram = @bigram", conn);
cmd.Parameters.Add(new OleDbParameter("@bigram", ngram.Znakovi));
object NgramID = cmd.ExecuteScalar();
cmd.Dispose();
...

if (NgramID != null)
{
int iNgramID = (int)NgramID;

[b]cmd = new OleDbCommand("UPDATE BigramChar SET bigram_broj = bigram_broj + 1, bigram_txt = bigram_txt + 2 WHERE ID = @ID", conn);[/b]
cmd.Parameters.Add(new OleDbParameter("@ID", iNgramID));
...[/code]

he update fields with 1 or 2 it depends how much bigrams he found.
bigram is for example from word = "preview"
1. pr
2. re
3. ev
4. vi
5. ie
6. ew

can someone help me with this please
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories