PRIMARY KEY COLUMN NAME を取得する必要があります。という変数にテーブルの名前があります_lstview_item
今まで私はこのような列名を取得しようとしました
string sql = "SELECT ColumnName = col.column_name" +
"FROM information_schema.table_constraints tc" +
"INNER JOIN information_schema.key_column_usage col" +
"ON col.Constraint_Name = tc.Constraint_Name" +
"AND col.Constraint_schema = tc.Constraint_schema" +
"WHERE tc.Constraint_Type = 'Primary Key'" +
"AND col.Table_name = " +_lstview_item+ "";
SqlConnection conn2 = new SqlConnection(cc.connectionString(cmb_dblist.Text));
SqlCommand cmd_server2 = new SqlCommand(sql);
cmd_server2.CommandType = CommandType.Text;
cmd_server2.Connection = conn2;
conn2.Open();
string ColumnName = (string)cmd_server2.ExecuteScalar();
conn2.Close();
成功せずに。ヘルプ ?