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 paxPosted Nov 2, 2009, 3:15 AM
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.
faraz akramPosted Nov 2, 2009, 8:50 AM
cheers:|
Kirtan PatelPosted Nov 2, 2009, 6:54 AM
Send me your ProjectFiles(zip) at [email protected]
Will Quickly resolve it and send it back to you :)
Thank you :)