codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Data  sardinka at 16:19 on Thursday, March 17, 2005
 

What is the best way to keep data between pages (data can be change) and at the end submitted to the SQL database?
can you give me an example? Thanks

  Re: Data  raik at 09:35 on Friday, March 18, 2005
 

There are many ways to keep data of pages, the most simple way is as below
U can keep data with session variables for example
i want to a numeric value 2
Session.item("myValue",2)
and in nex page i can get it like below
Dim sessionvalue as Integer
sessionvalue =Session.item("myValue")




<Added>

in above lines i miss session.add in 4th line sorry
There are many ways to keep data of pages, the most simple way is as below
U can keep data with session variables for example
i want to a numeric value 2
Session.Add("myValue",2)
and in next page i can get it like below
Dim sessionvalue as Integer
sessionvalue =Session.item("myValue")


  Re: Data  sardinka at 13:45 on Friday, March 18, 2005
 

what about keeping dataset in session?
I have a user control on a first page with text boxes and I am thinking to put all data in ds, but I don't know how. Do you have an example how to do this? Thanks

  Re: Data  raik at 14:25 on Friday, March 18, 2005
 

First i dont know y u need dataset to keep values of textboxes, however u keep dataset in session like below.

session.add("SessionVariableName",DatasetName)

and u can get values of dataset like below

dim mydataset as Dataset=Ctype(Session.item("SessionVariableName"),DataSet)

dim myvalue =mydataset.tables(0).Rows(0).Item("NameofItem")

U can also iterate all dataset using for or foe each loop.

2nd Solution
============
If u want to keep values of ur 2 textboxes in user control write below 2 lines in ur user control.

Session.add("1stTextBoxValue",TextBox1.Text)
Session.add("2ndTextBoxValue",TextBox2.Text)

And in required page u can get ur textboxes values like below

Dim firstvalue as String=Session.item("1stTextBoxValue")
Dim secondvalue as String=Session.item("2ndTextBoxValue")

<Added>

Mistake
=======
U can also iterate all dataset using for or for each loop.

  Re: Data  sardinka at 17:55 on Friday, March 18, 2005
 

What I am trying to do is to submit a dataset to a sql instead of separate value for each box.

  Re: Data  raik at 19:08 on Friday, March 18, 2005
 

first import Namespace in top of ur page

Imports System.Data.SqlClient

then write below code in ur required event it will pull all the the data in to SQL server


Dim myConn As New SqlConnection("ur Connection string")
myConn.Open()
Dim myCom As SqlCommand = myConn.CreateCommand()
myCom.CommandText = "Insert Into tablename(istfirld,2ndField) values('" + session.Item("istValue+"','"+ Session.item("senondValue")+"')"
myCom.ExecuteNonQuery()
myConn.Close()








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Use of VB .NET
•  Cookies and new pages
•  need help with e-mail validation
•  Problems with DHTML dropdown menus
•  Re: Passing values from a select box to a text box
•  lowerCase to UpperCase
•  Re: Javascript validation that will stop a ` (apostrophe) being entered
•  Re: pop-up Javascript calendar
•  nested classes


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005