Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-11-09 : 08:18:59
|
| Mihai writes "Ok, so say i have an array of results from a previous query, how can i pass those as a single parameter so that they would be excluded from the search (or included, or whatever)example:connection.Open();System.Data.SqlClient.SqlCommand selectwithExclude = new System.Data.SqlClient.SqlCommand("SELECT * FROM MainTable WHERE Value != @Value", connection);int [] values = {1,2};selectwithExclude.Parameters.AddWithValue("@Value", values);IDataReader reader = selectwithExclude.ExecuteReader();int returnValue = 0;while (reader.Read()){ returnValue = reader.GetInt32(2);}reader.Dispose();connection.Close();MessageBox.Show(returnValue.ToString());This for instance would throw me an exception saying that "No mapping exists from object type System.Int32[] to a known managed provider native type.", exception to which i aggree, as i've shown this example simply as to demonstrate what i'm after.I would also like to avoid building a huge query string that would include a "AND Value !=@Value1 AND Value != @Value2" and so on, as the search results can get an enormous number of items.Thank you in advance." |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|