asp.net


Data table + session = Shopping cart


GM everybody
i'm finding some issues in the implementation of my shopping cart
The query works but it doesn't store information in session.
Will i fix the query or the problem is the session ?
Here the code :
Dim constr As String = ConfigurationManager.ConnectionStrings("!aCommerce-ConnectionString!").ConnectionString
' Query SQL
Using cmd As New SqlCommand("SELECT Id,NomeProdotto, PrezzoProdotto, Quantità FROM aProdotti WHERE ID='" + Request.QueryString("ID").ToString + "' OR ID='" + Request.QueryString("ID").ToString + "'")
Using sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
Session("dt") = dt
sda.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End Using
End Using
End Using
change you code to below
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection()
con.ConnectionString = constr
con.Open()
' Query SQL
Using cmd As New SqlCommand("SELECT Id,PromoCode as NomeProdotto,PromoCodeMessage as PrezzoProdotto, PromoCodeLimit as Quantità FROM EventPromocodetbl WHERE ID=" & Request.QueryString("ID").ToString & "", con)
Using sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
Dim SessionDt As New DataTable()
SessionDt = Session("dt")
If Not SessionDt Is Nothing Then
If (dt.Rows.Count > 0) Then
Dim dr As DataRow
dr = SessionDt.NewRow()
dr("Id") = dt.Rows(0)("Id").ToString()
dr("NomeProdotto") = dt.Rows(0)("NomeProdotto").ToString
dr("PrezzoProdotto") = dt.Rows(0)("PrezzoProdotto").ToString
dr("Quantità") = dt.Rows(0)("Quantità").ToString
SessionDt.Rows.Add(dr)
End If
Session("dt") = SessionDt
GridView1.DataSource = SessionDt
GridView1.DataBind()
Else
Session("dt") = dt
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Using
End Using
Problem is you are assigning blank DatatTable to session and then you are filling that DataTable using DataAdapter fill method that is issue.

Related Links

how to show submenu with sitemap in asp .net?
Accessing Email Client from ASP.NET Web Page
How to Import MicroSoft Access Database (mdb) into SQL Express File using SQLCMD?
Allowing break/new line from Text area in Regex
SMTP host status in ASP.NET
DetailsView resetting visibility on bind?
run .exe at client side from .aspx.cs page
Access ASP.Net rolesprovider from external assembly
Changing the CreatedBy convention in Subsonic (3x)
Sql transaction and rollback in asp .net can it be used for MS Access
Capturing ASP.Net Server Execution time without Network Latency
Can I detect if SSL/https is enabled for an ASP.NET website from within the site's code?
Trailing zero on decimal
how to set width size in rdl using vs 2008?
How can I call an oracle function as part of a parameterized query?
How to fix ViewState serialization error with my custom control?

Categories

HOME
twitter-bootstrap
qemu
snappy
azure-eventhub
data-modeling
arguments
assign
crash
symfony-sonata
glympse
cdn
markdown
osx-yosemite
wkhtmltopdf
phpexcel
normals
xmlhttprequest
hdf5
web-testing
infopath
owncloud
internet-explorer-7
datasource
beaker-notebook
devexpress-mvc
oracle10g
smart-device
multiple-inheritance
jbossfuse
xlib
jboss-arquillian
edsdk
imdb
jsonapi-resources
fastadapter
mootools
gitosis
flex3
kofax
dotnetnuke-module
redhat-brms
const
instances
ng-lightning
ui-grid
susy
amazon-rds-aurora
python-venv
amazon-fire-tv
reqif
mef
hdpi
cloudconvert
wink
typewriter
liferay-ide
multi-targeting
rmq
robotc
boost-range
foreground
diameter-protocol
boost-bind
shtml
pebble-js
radar-chart
bbedit
factorization
jsondoc
askbot
ewam
encode
magnet-uri
taverna
notice
textblob
avrcp
callfire
system.diagnostics
httpmodule
ultraedit
skview
cl.exe
frisby.js
novell
register-allocation
powerpoint-2010
step
yandex-api
email-headers
kernel-density
scidb
fade
pechkin
ironworker
oc4j
dd4t
proj4
coinbase-php
brew
auctex
big-endian
cgaffinetransform
clgeocoder
rjs
mismatch
object-tag
llblgen
arraycollection
jquery-attributes
p4.net
xslt-grouping
qprocess
uccapi
script-tag
unauthorized

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App