Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When I add password to my SQL compact 3.5 database , the auto complete function for the textbox stops working (although I can connect normally to the database with the application.. Namely the connection is functioning properly).

All the settings are the same as I did only add the password to the connection string.

Working auto complete :
C#
SqlCeConnection sqlcon = new SqlCeConnection(@"Data Source = TranslationTest.sdf");
        SqlCeCommand sqlcmd;
        SqlCeDataReader sqldr;
        AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
        
private void Form1_Load(object sender, EventArgs e)
        {

            try {
  sqlcon.Open();
  sqlcmd = new SqlCeCommand("SELECT EnglishWord,ArabicWord FROM T1", sqlcon);
  sqldr = sqlcmd.ExecuteReader();
  AutoCompleteStringCollection mycollection = new AutoCompleteStringCollection();
  while (sqldr.Read())
  {    mycollection.Add(sqldr.GetString(0));         }
  textBox1.AutoCompleteCustomSource = mycollection;
  sqlcon.Close();  }

            catch (Exception ex)
  {   MessageBox.Show(ex.Message);    }
        }


Not working (with password) :
C#
SqlCeConnection sqlcon = new SqlCeConnection(@"Data Source = TranslationTest.sdf;Password=778899;");
        SqlCeCommand sqlcmd;
        SqlCeDataReader sqldr;
        AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
        
private void Form1_Load(object sender, EventArgs e)
        {

            try {
  sqlcon.Open();
  sqlcmd = new SqlCeCommand("SELECT EnglishWord,ArabicWord FROM T1", sqlcon);
  sqldr = sqlcmd.ExecuteReader();
  AutoCompleteStringCollection mycollection = new AutoCompleteStringCollection();
  while (sqldr.Read())
  {    mycollection.Add(sqldr.GetString(0));         }
  textBox1.AutoCompleteCustomSource = mycollection;
  sqlcon.Close();  }

            catch (Exception ex)
  {   MessageBox.Show(ex.Message);    }
        }


Extras :
- Multiline = false
- Auto complete mode = suggest (tried Suggest & append .. the same problem)
- Password added with VS2010 http://i.imgur.com/2dSNtDo.jpg
Posted
Updated 13-Apr-15 2:09am
v2
Comments
ZurdoDev 13-Apr-15 10:53am    
What is the error?
Sherif Kamel 13-Apr-15 11:56am    
@RyanDev : no error , just the auto complete text box is not working when I add a password protected database (i.e it doesn't suggest results).
ZurdoDev 13-Apr-15 12:08pm    
I suggest putting a breakpoint and see what's happening.
Sherif Kamel 13-Apr-15 12:31pm    
Well , I'm sorry but I don't know how to use breakpoints :) forgive my ignorance.
ZurdoDev 13-Apr-15 13:09pm    
Just click the margin at sqlcon.Open(); or right-click and add breakpoint or select that line and press F9.

Then, when you run the code, it will stop at that point. Step through line by line and see what happens.

1 solution

As discussed in comments, after debugging the code you were able to find the issue and have it working now.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900