954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

split function in textbox and compare it to database

hello ! my thesis is all about language translation and im having a problem with the concatenation of strings in the textbox...because for example i input city kiss and it will display the ilocano(dialect) ili agek but when i input kiss city it still display ili agek

ishtine18
Newbie Poster
5 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Hi ishtine18, welcome on Daniweb!
Could you post some code?
Without it it is hard to solve your problem.

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

static string str_conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\Desktop\thesis(data).mdb";
private OleDbConnection conn;
private OleDbDataAdapter da;
private DataSet ds;
private OleDbCommand Dictionary;
private OleDbDataReader dr;
string[] strSplit;
string strOne;

private void button1_Click(object sender, EventArgs e)
{
//strOne = textBox1.Text;
if (textBox1.Text == "")
{
MessageBox.Show("Please Enter Text in the Textbox!");
label5.Text = "";
}

if (comboBox2.SelectedItem == "Ilocano" && comboBox1.SelectedItem == "English")
{
strOne = textBox1.Text;
string seperator = "";
strSplit = textBox1.Text.Split(seperator.ToCharArray());
string complete = "";

foreach (string x in strSplit)
{
complete = complete + "'" + x.ToString() + "',";
}

Dictionary = new OleDbCommand("Select Ilokano FROM Dictionary where English IN ("+ complete + "'')", conn);
Dictionary.CommandType = CommandType.Text;
Dictionary.Connection = conn;
dr = Dictionary.ExecuteReader();
while (dr.Read())
{
label5.Text = label5.Text + " " + dr["Ilokano"].ToString();
}

}
else if (comboBox1.SelectedItem == "Ilocano" && comboBox2.SelectedItem == "English")
{
//strOne = textBox1.Text;
//string seperator = "";
//strSplit = textBox1.Text.Split(seperator.ToCharArray());
//string complete = "";
//foreach (string x in strSplit)
//{
// complete = complete + "'" + x.ToString() + "',";
//}

Dictionary = new OleDbCommand("Select English FROM Dictionary where Ilokano like" + "'%" + textBox1.Text + "%'", conn);
Dictionary.CommandType = CommandType.Text;
Dictionary.Connection = conn;
dr = Dictionary.ExecuteReader();
dr.Read();
//while (dr.Read())
//{
label5.Text = dr["English"].ToString();
//}
}


}

ishtine18
Newbie Poster
5 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Please use code tags when you send some code.
Isn't it a problem you use both "llocano" and "llokano"?

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 
Please use code tags when you send some code. Isn't it a problem you use both "llocano" and "llokano"?


okay sorry..im just new here :)

Ilocano is the name in the combobox..and Ilokano is the name of a column in the database...
and as i see its like the first data in the database is the one will be displayed first..hmm

ishtine18
Newbie Poster
5 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 
int LastSep=0;
for (int i=0; i< textBox1.Text.Length;i++)
{
  if (textBox1.Text[i] == ' ')
  {
    label5.Text += new OleDbCommand("Select English FROM Dictionary where Ilokano like" + "'%" +  textBox1.Text.SubString(LastSep,i-LastSep) + "%'", conn).ExecuteScaler().toString() + " ";
    LastSep=i;
  }
  if (i == textBox1.Text.Length-1 && textBox1.Text[textBox1.Text.Length-1] != ' ')
  {
        label5.Text += new OleDbCommand("Select English FROM Dictionary where Ilokano like" + "'%" +  textBox1.Text.SubString(LastSep,i-LastSep) + "%'", conn).ExecuteScaler().toString();
  }
}

Try this
I didn't have a compiler so there maybe syntax errors

Please let me know if you need clarification

I don't see where you opened the Connection

finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
 

string s = txtValue.Text;
char[] delimeter={',','@','$',' ','#','%','*','\t'};
string[] word = s.Split(delimeter);
txtFName.Text = word[0];
txtLName.Text = word[1];
txtAge.Text = word[2];
txtDOB.Text = word[3];

Iswariya
Newbie Poster
1 post since Oct 2011
Reputation Points: 8
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: