ich eine Methode erstellt haben, die alle Tabellen mit Primärschlüssel in einem Drop-Down-ähnlicheMethode funktioniert nicht richtig
public void PrimaryKeyTable()
{
SqlConnection sConnection = new SqlConnection("Server=192.168.10.3;DataBase=GoalPlanNew;User Id=gp;Password=gp");
//To Open the connection.
sConnection.Open();
string selectPrimaryKeys = @"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'
ORDER BY TABLE_NAME";
SqlCommand sCommand = new SqlCommand(selectPrimaryKeys, sConnection);
try
{
DataSet dsListOfPrimaryKeys = new DataSet("INFORMATION_SCHEMA.TABLE_CONSTRAINTS");
SqlDataAdapter dass = new SqlDataAdapter(selectPrimaryKeys, sConnection);
dass.TableMappings.Add("Table", "INFORMATION_SCHEMA.TABLE_CONSTRAINTS");
dass.Fill(dsListOfPrimaryKeys);
DataViewManager dsvaa = dsListOfPrimaryKeys.DefaultViewManager;
cmbResults.DataSource = dsListOfPrimaryKeys.Tables["INFORMATION_SCHEMA.TABLE_CONSTRAINTS"];
cmbResults.DisplayMember = "NAME";
cmbResults.ValueMember = ("");
}
catch (Exception ex)
{
//All the exceptions are handled and written in the EventLog.
EventLog log = new EventLog("Application");
log.Source = "MFDBAnalyser";
log.WriteEntry(ex.Message);
}
finally
{
if (sConnection.State != ConnectionState.Closed)
{
sConnection.Close();
}
}
}
sondern binden die Tabellen mit Primärschlüssel binden würde es so etwas wie dies in der schenkt dropdown
System.Data.DataRowView
System.Data.DataRowView...and so on
Kannst du plz darauf hinweisen, wo ich falsch gelaufen bin?
sind Sie diese Linie sicher 'cmbResults.DisplayMember =" NAME ";' Spaltenname ist '" NAME "' – FosterZ