Я пытаюсь извлечь детали столбцов базы данных MySQL с следующими деталями:не получают столбцы конкретных таблиц MySQL
- Имя базы данных = студент
- Table Name = student_detail
код :
String[] columnRestrictions = new String[4];
// For the array, 0-member represents Catalog;
// 1-member represents Schema;
// 2-member represents Table Name; 3-member represents Column Name.
// Now we specify the Table_Name and Column_Name of the columns what we want to get schema information.
//Reference:https://msdn.microsoft.com/en-us/library/ms136366(v=vs.110).aspx
columnRestrictions[0] = 'student';
columnRestrictions[1] = 'student';
columnRestrictions[2] = 'student_detail'
DataTable allColumnsSchemaTable = con.GetSchema("Columns"); //giving me all columns of all tables
// not getting columns
var cols = con.GetSchema("Columns", new string[] { 'student','student' "student_detail" }).AsEnumerable().Select(col => col["COLUMN_NAME"].ToString()).ToArray();
// not getting columns
var cols = con.GetSchema("Columns", new string[] { 'student',"student_detail" }).AsEnumerable().Select(col => col["COLUMN_NAME"].ToString()).ToArray();
В настоящее время работает отлично, но дает мне все столбцы всех таблиц:
DataTable allColumnsSchemaTable = con.GetSchema("Columns"); //giving me all columns of all tables
Я хочу получить столбцы конкретных таблиц.
Update: В моем исследовании я обнаружил, что там нет ничего, как схемы в MySQL, которая находится в MSSQL так в MySQL схемы и базы данных являются одинаковыми
Это неправильный строковый массив. '{'student', 'student'" student_detail "}'. Строки должны иметь qutoes '' 'и между student и student_detail, должна быть другая запятая. – Phiter
@PhiterFernandes Извините, что это была ошибка, но это не проблема –
попробуйте http://stackoverflow.com/questions/17353089/get-the -column-names-of-a-table-and-store-them-in-a-string-or-var-c-sharp-asp-ne – Damith