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 include file to (vb)
How to retrieve adwords reports to datatable using api adwords in asp.net c#
How to link a logged in user to a Facebook Identity provider in Okta
how could i select the name of higest and lowest paid salaries..?
How to count total selected files on AjaxFileUpload on change java script
Textbox asp.net postback trigger twice on autopostback true
Crsytall Report is not showing in web page asp.net
Using Active Directory authentication on a internal website
Why is my date comparison not working?
Startup fails after deployment when using connection strings configSource attribute along with Azure App Service environment connection strings
How do I change the html panel using asp: LinkButton
Generate heatmap inside asp.net webpage include master pages
Error after deploying asp.net core app to azure
asp.net GridView textbox filter on change
machine.config pros and cons for assembly redirection for a code behind dependency
Redirect to HTTPS on IIS behind an AWS Load balancer doesn't work in IE

Categories

HOME
internet-explorer
ckan
javafx
twitter-bootstrap
stanford-nlp
virtual-machine
network-programming
spotfire
nltk
opengl-es
mediarecorder
multipartform-data
browserstack
yacc
dcos
wowza
background-image
serenity-js
mattermost
my.cnf
sqldependency
andengine
intermec
ibm-bpm
android-scrollview
device-driver
icu
delphi-xe
html-entities
infovis
automapper-4
rivets.js
vertex
gige-sdk
multi-select
spring-social-twitter
zsh-completion
airwatch
video-embedding
hana-sql-script
jersey-test-framework
instabug
videoview
cascading
controlpanel
producer-consumer
borland-c++
eggplant
vspackage
data-representation
radgrid
copy-on-write
connection-timeout
wingdb
pymol
data-quality-services
nexusdb
cl.exe
douglas-peucker
touch-typing
crystal-reports-7
pnunit
indic
cs193p
starling-framework
xml-validation
google-oauth-java-client
8-puzzle
mandelbrot
uikit-dynamics
pymel
auctex
dnsbl
volatility
junit-rule
inflate
report-viewer2010
php-gettext
google-email-audit-api
advanceddatagrid
pinchzoom
scriptmanager
jexcelapi
moss2007-security
html5-animation
s60
activescaffold
pitch-shifting
system-analysis
hp-trim
dynamic-scope
authkit
bootstrap-protocol
httpbrowsercapabilities
software-update
high-load
scalable

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