Problem in dynamic sql - Table Adapters C# 2008
hi ,
i have developed a search screen that takes dynamic "where" clause in sql select on runtime depend upon user input.
the code is mentioned below....
--------------------------------------------------
OdbcConnection odbc_conn = new OdbcConnection("connection string");
OdbcDataAdapter odbc_da = new OdbcDataAdapter("select * from my_table" + whereclause, odbc_conn);
odbc_da.FillSchema(dataSet1, System.Data.SchemaType.Source, "my_table");
odbc_da.Fill(dataSet1, "my_table");
my_table.BindingSource.DataSource = dataSet1.Tables["my_table"];
--------------------------------------------------
"Fill" is the query that i created in the
dataset1 designer the normal through wizard in the my_tabletableadapter.
Now first time it works fine and selecting the data on basic of parameters in "WHERECLAUSE" but second time it does not override the previous sql with a new sql , where clause is changing prperly on user input but the time when it comes on this line of code
odbc_da.FillSchema(dataSet1, System.Data.SchemaType.Source, "my_table");
it shows the previous dataset ,
any help
regards
fazy sam

naura paxRank #2,843 · 502 reputationPosted Nov 1, 2009, 10:15 PM EST
it will show previous dataset values its only after that line that dataset1's value should change anyways to make it work you can write this before da.Fill:
dataset1.Clear();
I hope this would work.
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 2, 2009, 1:54 AM EST
Send me your ProjectFiles(zip) at [email protected]
Will Quickly resolve it and send it back to you :)
Thank you :)
faraz akram83 reputationPosted Nov 2, 2009, 3:50 AM EST
cheers:|