DataGrid Problem

Hi all... I've got a problem.. i am trying to do a e-commerce application in Microsoft.NET web matrix program that will retrieve all the orders when i click on the button.
In my design mode, i have a datagrid and a button.
In the code mode, i inserted these codes:
---------------------------------------------------------------
Sub Button1_Click(sender As Object, e As EventArgs)
    Dim wsProxy as new IBuySpy.InstantOrder()

    Dim userName As String
    Dim password As String
    Dim orderID As Integer

    DataGrid.DataSource = wsProxy.CheckStatus(userName,password,orderID)
    DataGrid1.DataBind()
End Sub
----------------------------------------------------------
I think i did not declare the variable correctly. Can anyone help me to correct it? I don't know how to make the page work...
Thanks lots..
p0217859_05Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

samtran0331Commented:
are you sure that the function:
wsProxy.CheckStatus(userName,password,orderID)

returns something a datagrid can bind to? like a datatable or something?
a function named "CheckStatus" would make me think it returns a boolean or string or something...
error messages?

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
p0217859_05Author Commented:
i am not sure...
i have this in a file called InstantOrder.asmx


<%@ WebService Language="VB" Class="InstantOrder" %>

Imports System
Imports System.Web.Services
Imports ASPNET.StarterKit.Commerce

Public class InstantOrder : Inherits WebService

    '*******************************************************
    '
    ' InstantOrder.OrderItem() Method
    '
    ' The OrderItem method enables a remote client to programmatically
    ' place an order using a webservice.
    '
    '*******************************************************

    <WebMethod(Description:="The OrderItem method enables a remote client to programmatically place an order using a WebService.", EnableSession:=false)> _
    Public Function OrderItem(ByVal userName As String, ByVal password As String, ByVal productID As Integer, ByVal quantity As Integer) As Integer

        ' Login client using provided username and password
        Dim accountSystem As ASPNET.StarterKit.Commerce.CustomersDB = New ASPNET.StarterKit.Commerce.CustomersDB()
        Dim customerId As String = accountSystem.Login(userName, ASPNET.StarterKit.Commerce.Security.Encrypt(password))

        If customerId Is Nothing Then
            Throw New Exception("Error: Invalid Login!")
        End If

        ' Wrap in try/catch block to catch errors in the event that someone types in
        ' an invalid value for quantity
        Dim qty As Integer = System.Math.Abs(quantity)
        If qty = quantity And qty < 1000 Then

            ' Add Item to Shopping Cart
            Dim myShoppingCart As ASPNET.StarterKit.Commerce.ShoppingCartDB = New ASPNET.StarterKit.Commerce.ShoppingCartDB()
            myShoppingCart.AddItem(customerId, productID, quantity)

            ' Place Order
            Dim orderSystem As ASPNET.StarterKit.Commerce.OrdersDB = New ASPNET.StarterKit.Commerce.OrdersDB()
            Dim orderID As Integer = orderSystem.PlaceOrder(customerId, customerId)

            ' Return OrderDetails
            Return orderID
        Else
            ' invalid input
            Return Nothing
        End If

    End Function

    '*******************************************************
    '
    ' InstantOrder.CheckStatus() Method
    '
    ' The CheckStatus method enables a remote client to programmatically
    ' query the current status of an order in the Commerce System.
    '
    '*******************************************************

    <WebMethod(Description:="The CheckStatus method enables a remote client to programmatically query the current status of an order in the ASPNETCommerce System.", EnableSession:=false)> _
    Public Function CheckStatus(ByVal userName As String, ByVal password As String, ByVal orderID As Integer) As OrderDetails

        ' Login client using provided username and password
        Dim accountSystem As ASPNET.StarterKit.Commerce.CustomersDB = New ASPNET.StarterKit.Commerce.CustomersDB()
        Dim customerId As String = accountSystem.Login(userName, ASPNET.StarterKit.Commerce.Security.Encrypt(password))

        If customerId = "" Then
            Throw New Exception("Error: Invalid Login!")
        End If

        ' Return OrderDetails Status for Specified Order
        Dim orderSystem As ASPNET.StarterKit.Commerce.OrdersDB = New ASPNET.StarterKit.Commerce.OrdersDB()
        Return orderSystem.GetOrderDetails(orderID, customerId)

    End Function

   <WebMethod> Function GetOrders() As System.Data.DataSet
        Dim connectionString As String = "server='(local)'; user id='sa'; password='346Password'; database='Commerce'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

        Dim queryString As String = "SELECT [CMRC_OrderDetails].[OrderID], [CMRC_OrderDetails].[ProductID], [CMRC_Cust"& _
"omers].[EmailAddress], [CMRC_Customers].[CustomerID], [CMRC_OrderDetails].[UnitC"& _
"ost], [CMRC_OrderDetails].[Quantity], [CMRC_Customers].[FullName], [CMRC_Custome"& _
"rs].[Password] FROM [CMRC_OrderDetails], [CMRC_Customers]"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
        dataAdapter.SelectCommand = dbCommand
        Dim dataSet As System.Data.DataSet = New System.Data.DataSet
        dataAdapter.Fill(dataSet)

        Return dataSet
    End Function
End Class
--------------------------------------------------------------------------------------
and using this, i created another aspx page, and created a proxy linked to the asmx page.
i now want to display username, password and orderID, but i am only able to everything that i extract from the database.
How do i specify the specific things i want to display?
0
p0217859_05Author Commented:
thanks for ur quick response.
the datagrid can display items, but it displays everything i have that i extracted from the database.
this is what i have in the asmx page that i used to generate a proxy with.

<%@ WebService Language="VB" Class="InstantOrder" %>

Imports System
Imports System.Web.Services
Imports ASPNET.StarterKit.Commerce

Public class InstantOrder : Inherits WebService

    '*******************************************************
    '
    ' InstantOrder.OrderItem() Method
    '
    ' The OrderItem method enables a remote client to programmatically
    ' place an order using a webservice.
    '
    '*******************************************************

    <WebMethod(Description:="The OrderItem method enables a remote client to programmatically place an order using a WebService.", EnableSession:=false)> _
    Public Function OrderItem(ByVal userName As String, ByVal password As String, ByVal productID As Integer, ByVal quantity As Integer) As Integer

        ' Login client using provided username and password
        Dim accountSystem As ASPNET.StarterKit.Commerce.CustomersDB = New ASPNET.StarterKit.Commerce.CustomersDB()
        Dim customerId As String = accountSystem.Login(userName, ASPNET.StarterKit.Commerce.Security.Encrypt(password))

        If customerId Is Nothing Then
            Throw New Exception("Error: Invalid Login!")
        End If

        ' Wrap in try/catch block to catch errors in the event that someone types in
        ' an invalid value for quantity
        Dim qty As Integer = System.Math.Abs(quantity)
        If qty = quantity And qty < 1000 Then

            ' Add Item to Shopping Cart
            Dim myShoppingCart As ASPNET.StarterKit.Commerce.ShoppingCartDB = New ASPNET.StarterKit.Commerce.ShoppingCartDB()
            myShoppingCart.AddItem(customerId, productID, quantity)

            ' Place Order
            Dim orderSystem As ASPNET.StarterKit.Commerce.OrdersDB = New ASPNET.StarterKit.Commerce.OrdersDB()
            Dim orderID As Integer = orderSystem.PlaceOrder(customerId, customerId)

            ' Return OrderDetails
            Return orderID
        Else
            ' invalid input
            Return Nothing
        End If

    End Function

    '*******************************************************
    '
    ' InstantOrder.CheckStatus() Method
    '
    ' The CheckStatus method enables a remote client to programmatically
    ' query the current status of an order in the Commerce System.
    '
    '*******************************************************

    <WebMethod(Description:="The CheckStatus method enables a remote client to programmatically query the current status of an order in the ASPNETCommerce System.", EnableSession:=false)> _
    Public Function CheckStatus(ByVal userName As String, ByVal password As String, ByVal orderID As Integer) As OrderDetails

        ' Login client using provided username and password
        Dim accountSystem As ASPNET.StarterKit.Commerce.CustomersDB = New ASPNET.StarterKit.Commerce.CustomersDB()
        Dim customerId As String = accountSystem.Login(userName, ASPNET.StarterKit.Commerce.Security.Encrypt(password))

        If customerId = "" Then
            Throw New Exception("Error: Invalid Login!")
        End If

        ' Return OrderDetails Status for Specified Order
        Dim orderSystem As ASPNET.StarterKit.Commerce.OrdersDB = New ASPNET.StarterKit.Commerce.OrdersDB()
        Return orderSystem.GetOrderDetails(orderID, customerId)

    End Function

   <WebMethod> Function GetOrders() As System.Data.DataSet
        Dim connectionString As String = "server='(local)'; user id='sa'; password='346Password'; database='Commerce'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

        Dim queryString As String = "SELECT [CMRC_OrderDetails].[OrderID], [CMRC_OrderDetails].[ProductID], [CMRC_Cust"& _
"omers].[EmailAddress], [CMRC_Customers].[CustomerID], [CMRC_OrderDetails].[UnitC"& _
"ost], [CMRC_OrderDetails].[Quantity], [CMRC_Customers].[FullName], [CMRC_Custome"& _
"rs].[Password] FROM [CMRC_OrderDetails], [CMRC_Customers]"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
        dataAdapter.SelectCommand = dbCommand
        Dim dataSet As System.Data.DataSet = New System.Data.DataSet
        dataAdapter.Fill(dataSet)

        Return dataSet
    End Function
End Class
---------------------------------------------------------------------------------------------------------
using this, i managed to display all the items, however, i need to only display the username, password and orderID.
how do i declare the items i want to display?
0
samtran0331Commented:
CheckStatus returns a "getOrderDetails"...which you didn't post...but I'm going to assume it is just like "GetOrders" and returns a dataset...in which case if you wanted to use the same dataset and just pull one value into a textbox or something...you can try...

        Dim ds As DataSet = New DataSet
        ds = wsProxy.CheckStatus(userName,password,orderID)
        Dim strUsername As String = ds.Tables(0).Rows(0)("FullName").ToString()


0
p0217859_05Author Commented:
thanks.. i solved it.. :D sorry took so long...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.