Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

table programatically

Posted on 2009-03-30
8
Medium Priority
?
167 Views
Last Modified: 2012-05-06
' If I have the cartid as static like. "38400d3a-9451-41b1-b1d6-5910073af288" then my data shows up.
        ' But when I try to delcare it I see no data. this has droven me banannas. Please
        ' if anyone sees anything that I cannot see or should work .

prm = New SqlParameter("@CartID", SqlDbType.Char, 36)
        prm.Direction = ParameterDirection.Input
        prm.Value = CartID "38400d3a-9451-41b1-b1d6-5910073af288"
        cmd.Parameters.Add(prm)

Dim Header(100, 5)
        Dim hWeek As Integer = 0
        Dim hDept As String = ""
        Dim widx As Integer = -1
 
        Dim conn As New SqlConnection(Application("A1SConnString"))
        Dim cmd As SqlCommand
        Dim prm As SqlParameter
        cmd = New SqlCommand("GetShoppingCartProducts", conn)
 
        Dim c As TableCell
        Dim r As TableRow
        '-----------------------------------------------
 
        Dim CartID As Char
        ''I have a table I am programatically showing. The problem is passing the Parameter for cartid. 
        
        prm = New SqlParameter("@CartID", SqlDbType.Char, 36)
        prm.Direction = ParameterDirection.Input
        prm.Value = "38400d3a-9451-41b1-b1d6-5910073af288"
        cmd.Parameters.Add(prm)
 
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandTimeout = 120 'Number of seconds to wait for a response.
 
        Dim sqlDR As SqlDataReader
        conn.Open()
        sqlDR = cmd.ExecuteReader(CommandBehavior.Default)

Open in new window

0
Comment
Question by:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 13

Accepted Solution

by:
hiteshgoldeneye earned 2000 total points
ID: 24026949
hi, u have mentioned
 prm.Value = CartID "38400d3a-9451-41b1-b1d6-5910073af288"
 are u appending CartId to 38400d3a-9451-41b1-b1d6-5910073af288 ?
if yes then i thing u need 37 chars and u need to change
prm = New SqlParameter("@CartID", SqlDbType.Char, 36) to
prm = New SqlParameter("@CartID", SqlDbType.Char, 37)

Let me know if this helps
 
0
 
LVL 9

Author Comment

by:Seven price
ID: 24028623
Sorry that did not work. So weird , maybe you think it is the way i delcared it.

 Dim CartID As Integer

I have no idea.
0
 
LVL 13

Assisted Solution

by:hiteshgoldeneye
hiteshgoldeneye earned 2000 total points
ID: 24028822
to be frank u i did not understand the use of CartId in the following statement
prm.Value = CartID "38400d3a-9451-41b1-b1d6-5910073af288"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Author Comment

by:Seven price
ID: 24028907
Do i suppose to change what i have to what you have. Not using the cmd

Dim CartID As Integer
        prm = cmd.Parameters.Add("@CartID", SqlDbType.Char, 36)
        prm.Value = CartID
        
 
 
 Dim CartID As Integer
        prm = New SqlParameter("@CartID", SqlDbType.Char, 36)
        prm.Value = CartID

Open in new window

0
 
LVL 9

Author Comment

by:Seven price
ID: 24028923
Well the cartid is passed to another table one the user add to cart. this is a cookie that is inside the user machine. and the userid. I am just trying to pull the information to the table. I know this work because I done this by binding but for this particular problem i have to do this programatically.
0
 
LVL 9

Author Comment

by:Seven price
ID: 24029018
even tryied this way.

Dim prm As New SqlParameter("@CartID", SqlDbType.Char, 36)
        cmd.CommandType = CommandType.StoredProcedure
        prm.Value = CartID
        cmd.Parameters.Add(prm)

Open in new window

0
 
LVL 13

Assisted Solution

by:hiteshgoldeneye
hiteshgoldeneye earned 2000 total points
ID: 24029042
u have used
prm.Value = CartID

what is the value of CartId?, where are you assigning a value to it?
0
 
LVL 9

Author Comment

by:Seven price
ID: 24029133
I fix it I had to change the stored procedure to @cartid  to cartid
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question