C# 自动完成不';无法使用SQL Server CE密码保护的数据库
当我向SQL Server Compact Edition 3.5数据库添加密码时,文本框的自动完成功能停止工作(尽管我可以使用应用程序正常连接到数据库..即连接正常) 所有设置都与我所做的相同,只是在连接字符串中添加了密码 工作自动完成:C# 自动完成不';无法使用SQL Server CE密码保护的数据库,c#,winforms,sql-server-ce,C#,Winforms,Sql Server Ce,当我向SQL Server Compact Edition 3.5数据库添加密码时,文本框的自动完成功能停止工作(尽管我可以使用应用程序正常连接到数据库..即连接正常) 所有设置都与我所做的相同,只是在连接字符串中添加了密码 工作自动完成: SqlCeConnection sqlcon = new SqlCeConnection(@"Data Source = TranslationTest.sdf"); SqlCeCommand sqlcmd; SqlCeDataReader sqldr; A
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);
}
}
不工作(使用密码):
额外费用:
- 多行=假
- 自动完成模式=建议(尝试建议和附加..相同的问题)
- 与VS2010一起添加的密码
希望这能帮助将来可能面临相同问题的任何人任何错误-您不能简单地向现有数据库添加密码,您需要使用新的连接字符串压缩密码。@ErikEJ,不,先生,您搞错了我。我的意思是当我使用另一个受密码保护的数据库时。因此,除了自动完成文本框文本,当它停止提示结果时,它在其他所有方面都能完全发挥作用。
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);
}
}