Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
hi am using dynamic in my web application..
am using user control(BidTree)
i want to save this user controls values from session to sql table can any one suggest me how to give code to save into sql table.
 
thanks.
Posted 8-Jun-12 0:13am
ythisbug2.1K
Comments
digimanus at 21-Aug-14 6:06am
   
what have you tried? You can read values from session, set them as SqlParameter and fire a query with thee parameters to your database table? What part is to hard to handle for you?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Adding DataTable into Session:
DataTable Tissues = new DataTable();
 
Tissues = dal.returnTissues("TestID", "TestValue");// returnTissues("","") sample     function for adding values

Session.Add("Tissues", Tissues);
 
Retrive that datatable from session:
DataTable Tissues = Session["Tissues"] as DataTable
Or
DataTable Tissues = (DataTable)Session["Tissues"];
Ref:Storing and retrieving datatable from session[^]
  Permalink  
Comments
ythisbug at 8-Jun-12 5:42am
   
thanks can u explain me,.wat is TestID,TestValue ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Lets say you have a datatable ad you want to save it, say Dt.
Session["myTable"] = Dt;
Now on the page where you need to access it:
DataTable table = Session["myTable"] as DataTable;
 
if(table != null)
{
 //read table and push in Sqlserver
}
else
{
 //session either expired or invalid page being accessed.
}
I hope it helps. let me know if you need more.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

public static void main(string agr[])
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Adding DataTable into Session Veriable:

Set into Session variable as
 
Session["MyDataTableSessionName"]= "MyDataTable"
 
i.e. DataTable myDataTable=new DataTable();
 
Session["MyDataTable"]= myDataTable;

Retrive that DataTable from Session:
 
DataTable myDataTable =(DataTable)Session["MyDataTable"];
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 21 Aug 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100