C# SQL Columns into ComboBox -


My SQL query is not leaving anything in the blankbox but the connection seems to be working, but when the loop does not seem to work . Can anyone tell me what is wrong with that?

  string sqltable = ("dbo.SLTDS_C" + id + "_ table"); SqlConnection con = New SqlConnection ("Data Source =" + Server + "; Initial Catalog =" + Database + "; Integrated Security =" + Security); Con.Open ();  

string name sqldatapull = ("choose name from syscolumns where id = object_id (" + + sqltable + "') by serial name");
SqlCommand CMD = New SqlCommand (sqldatapull), Con?);
CMD. Common Type = CommandType Text;
SQL Datarer Dr. = CMD Spare reader ();

while (Dr. Reid ()) {sqldatapull = dr [0]. Toasting (); ComboBox1.Items.Add (sqldatapull); } Dr. Close (); Con.Close ();

Correction code: string string sqldatapull = ("syscolumn select name where id = object_id ('+ sqltable +' ') order by command name");

That's because you include dbo. As part of the table name, if you do not see any schema in table names in TABLE_NAME , you will see that

  SELECT * from INFORMATION_SCHEMA.COLUMNS  

column.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -