private string connectionString = @"Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" + @"Data Source=..\\..\\..\\MusicDatabase.sdf";
try
{
DataTable table = new DataTable();
string command = getcommand.CheckuserName(usernametb);
MessageBox.Show(command);
OleDbDataAdapter adapter = new OleDbDataAdapter(command, connectionString);
// do the query
table.Clear();
int recordCount = adapter.Fill(table); // Error
// display results
if (recordCount != 0)
{
MessageBox.Show("Username not available!");
}
else
{
}
}
catch (Exception obj)
{
MessageBox.Show(obj.ToString());
}
给我错误:指定的表格不存在[,,,,,]
我尝试了很多东西,但它不起作用。
getcommand.CheckuserName(usernametb);
返回:
public string CheckuserName(string usernametb)
{
string command = "SELECT * FROM USERS WHERE " +
"username = '" + usernametb + "'";
return command;
}
所以它返回:
SELECT * FROM USERS WHERE username = 'name'