sql server - C# using list table and text file to execute SQL query then export -


Scenario: I have a list table coming from Cambodia that can contain up to 50 things listed in the list table (in the list box The listed list is the column name). Hard part: I have a text file that matches a field in the SQL table. X1, X2, X3 are the listbox items.

So I basically need it:

  Select & lt; In the line text file & gt;, from & lt; Blah & gt; Where id = object_id ('table') export & lt; X2 & gt;, & lt; X3>, & lt; X4 & gt;, & lt; X5>, & lt; X6 & gt; C: \ Comma.text  

I do not need help listing catalogs, or SQL connections.

Just basically how do I list my listboxes in strings (no matter what order was selected in that order, to match based on Textfile, the SQL command And export it to it.)

I know that this is going to be a pain thanks to Advanice

Your question is not very clear ... the primary key in the text file is the value for the rows in the table?

If so, then your SQL proxy code will look like this:

  Select & lt; Selected column 1 & gt;, & lt; Selected column 2 & gt; ...  

How to get the list of items in a string in the primary keycell (& lt; yourTextFileValues ​​& gt;), and an SQL statement only Select the rows to export the database, here's a way:

  string [] selected column = new string [myListBox.SelectedItems.Count]; For (Int i = 0; I & lt; myListBox.SelectedItems.Count; i ++) {Selected column [i] = myListBox.SelectedItems [i] .ToString (); } String export column = string .join (",", selected column); // Format your SQL statement string sqlStatement = string.Format ("SelectTo {0} from yourTable WHERE blah = blah2", exportColumns);  

If everything in the list box is considered 'Selected' for export, then simply myListBox.SelectedItems to myListBox.Items Replace with


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

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