In VS2003 I have a user defaults table that I would call in the OnLoad - No Postback section to get the user defaults and then used some of the fields from that recordset as Parameters for other recordsets that would also load in that same section and might even issue a different Sql statement based on the field. In VS2005 (VB.NET), I can no longer figure out how to accomplish this. I can use the SQLDatasource Control which seems much improved but I cannot even find the generated code which I would use as a quick way to create my own datasources in the OnLoad event. Where is this code now stored and how can I accomplish my objectives in VB.NET 2005 with the current framework or programatically create data sources as necessary as I did before?
sorry if i missunderstand but do you WANT to create your own datasource? or do you want to modify the automagic one that vs2005 lets you drag onto your page?
|||I would like to know how to use both methods as I have done in the past. I have figured out how to configure through the "Smart Tag" but would like to be able to programatically alter the Automatic one and then also be able to take that code and use it in the OnLoad event as explained above if necessary. Thanks for your help.
|||if you use the automatic one.... good luck finding the code thats microsoft MAGIC (insert jazz hands here).
otherwise i would just create a dal layer/class and call youre stored proc something like this...
i like to put my create connection logic in a different method so everyone can use it.
private SqlCommand ConnectToIPSplit(string procedure) { ConnectionStringSettings conStr; conStr = ConfigurationManager.ConnectionStrings["myConfigConnection"]; SqlConnection conn =new SqlConnection(conStr.ConnectionString); SqlCommand command =new SqlCommand(procedure, conn); command.CommandType = CommandType.StoredProcedure;return command; }
============================
then i would do something like this to call the stored procedure and create a dataset
public DataSet GetByOwner(char owner) { DataSet ds =new DataSet(); SqlCommand command = ConnectToIPSplit("owner_Get"); SqlParameter paramOwner =new SqlParameter("@.Owner", owner); command.Parameters.Add(paramOwner);try { SqlDataAdapter dapter =new SqlDataAdapter(command); dapter.Fill(ds); }catch (Exception ext) { Console.WriteLine(ext);//catch exception }finally { command.Connection.Close(); }return ds; }
==================================
then you can go straight to the UI layer or have a business layer where you might have to hide or manipulate some data... i dunno im just sayin...
public void LoadItemSplitDetailGrid(string owner) { lblError.Text =""; lblError.Visible =false; ItemSplitDetailBLL bll =new ItemSplitDetailBLL();try { gvIPSplitItems.DataSource = bll.GetItemsByOwner(owner); gvIPSplitItems.DataBind(); }catch (ArgumentException ext) { lblError.Text = ext.Message; lblError.Visible =true; } }
============================bang bang boogie=====
then in your page load or wherever just call that load datagrid method
if you want to actually create the datasource object i usually avoid that ... but im just trying to help i didnt say i was a master see only 130 points
(by the way i know its not vb but i thought you would get it anyways youre a smart man...or woman...
sorry if this didnt help)
No comments:
Post a Comment