<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Free For All</title><link>http://forums.asp.net/12.aspx</link><description>Unmoderated open discussions for anything concerning Microsoft .NET and related technologies.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Amazon Web Services</title><link>http://forums.asp.net/thread/3274813.aspx</link><pubDate>Sat, 04 Jul 2009 16:24:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274813</guid><dc:creator>mattatuni2</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274813.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=12&amp;PostID=3274813</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Im trying to list all sellers for each book... the following code in VB and c# lists the books..&lt;/p&gt;
&lt;p&gt;VB&lt;/p&gt;
&lt;p&gt;==============&lt;/p&gt;&lt;pre class="vb.net" name="code"&gt;Imports System
Imports System.Data
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports com.amazon.webservices

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    End Sub


    Public Function AmazonToDataSet(ByVal PowerSearchString As String) As DataSet

        Dim ds As DataSet

        &amp;#39;have we this in the cache already? 
        If Cache(PowerSearchString) = Nothing Then
            &amp;#39;create our query 
            Dim response As ItemSearchResponse = grabAmazonSearch(PowerSearchString)

            &amp;#39;Construct the dataset to store the results 
            ds = New DataSet()
            ds.Tables.Add()

            ds.Tables(0).Columns.Add(&amp;quot;ProductName&amp;quot;)
            ds.Tables(0).Columns.Add(&amp;quot;AuthorName&amp;quot;)
            ds.Tables(0).Columns.Add(&amp;quot;Currency&amp;quot;)
            ds.Tables(0).Columns.Add(&amp;quot;Offer&amp;quot;)
            ds.Tables(0).Columns.Add(&amp;quot;ASIN&amp;quot;)
            ds.Tables(0).Columns.Add(&amp;quot;URL&amp;quot;)


            Dim info As Items = response.Items(0)
            &amp;#39; create new array with no size spec
            Dim items As Item() = info.Item
            Dim dr As DataRow

        

            &amp;#39;iterate the results adding new rows with 
            &amp;#39;the values from the search result item. 

            Dim i As Integer = 0
            While i &amp;lt; items.Length
             
                Dim item As Item = items(i)
                dr = ds.Tables(0).NewRow()
                dr(&amp;quot;ProductName&amp;quot;) = item.ItemAttributes.Title
                dr(&amp;quot;AuthorName&amp;quot;) = item.ItemAttributes.Author(0)
                dr(&amp;quot;Offer&amp;quot;) = item.Offers.Offer
                dr(&amp;quot;ASIN&amp;quot;) = item.ASIN
                dr(&amp;quot;Currency&amp;quot;) = item.ItemAttributes.ListPrice.CurrencyCode
                dr(&amp;quot;URL&amp;quot;) = item.DetailPageURL

                ds.Tables(0).Rows.Add(dr)
                System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            End While

            &amp;#39;add the dataset to the cache 

            Cache.Insert(PowerSearchString, ds, Nothing, DateTime.Now.AddHours(24), TimeSpan.Zero)
        Else
            ds = DirectCast(Cache(PowerSearchString), DataSet)
        End If
        &amp;#39;return the dataset 
        Return ds
    End Function


    Private Function grabAmazonSearch(ByVal PowerSearchString As String) As ItemSearchResponse
        Dim response As ItemSearchResponse

        Dim aws As New AWSECommerceService()
        Dim request As New ItemSearchRequest()
        request.SearchIndex = &amp;quot;Books&amp;quot;
        request.Power = PowerSearchString
        request.ResponseGroup = New String() {&amp;quot;Large&amp;quot;}
        request.MerchantId = &amp;quot;all&amp;quot;

        request.Sort = &amp;quot;salesrank&amp;quot;


        Dim requests As ItemSearchRequest() = New ItemSearchRequest() {request}
        Dim itemSearch As New ItemSearch()
        itemSearch.AssociateTag = &amp;quot;myassociatetag-20&amp;quot;
        itemSearch.SubscriptionId = &amp;quot;AKIAIAAGYTHFJS2RBSVQ&amp;quot;
        itemSearch.Request = requests
        response = aws.ItemSearch(itemSearch)

        Return response


    End Function






    Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        GridView1.DataSource = AmazonToDataSet(&amp;quot;title: &amp;quot; + TextBox1.Text)
        GridView1.DataBind()
    End Sub
End Class


=====================================&lt;/pre&gt;&lt;pre class="vb.net" name="code"&gt;c#&lt;/pre&gt;&lt;pre class="vb.net" name="code"&gt;&lt;pre class="c-sharp" name="code"&gt;using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.amazon.webservices;

public partial class _Default : System.Web.UI.Page 

{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
protected void Button1_Click(object sender, EventArgs e)
    {
        
      
       

         GridView1.DataSource = AmazonToDataSet(&amp;quot;title: &amp;quot; + TextBox1.Text);
         GridView1.DataBind();
            
}


public DataSet AmazonToDataSet(string PowerSearchString)
{

    DataSet ds;

    //have we this in the cache already? 
    if (Cache[PowerSearchString] == null)
    {
        //create our query 
        ItemSearchResponse response =
            grabAmazonSearch(PowerSearchString);

        //Construct the dataset to store the results 
        ds = new DataSet();
        ds.Tables.Add();

        ds.Tables[0].Columns.Add(&amp;quot;ProductName&amp;quot;);
        ds.Tables[0].Columns.Add(&amp;quot;AuthorName&amp;quot;);
        ds.Tables[0].Columns.Add(&amp;quot;Currency&amp;quot;);
        ds.Tables[0].Columns.Add(&amp;quot;Offer&amp;quot;);
        ds.Tables[0].Columns.Add(&amp;quot;ASIN&amp;quot;);
        ds.Tables[0].Columns.Add(&amp;quot;URL&amp;quot;);


        Items info = response.Items[0];
        // create new array with no size spec
        Item[] items = info.Item;
        DataRow dr;

        //iterate the results adding new rows with 
        //the values from the search result item. 

        for (int i = 0; i &amp;lt; items.Length; i++) //+
        {
            Item item = items[i];
            dr = ds.Tables[0].NewRow();
            dr[&amp;quot;ProductName&amp;quot;] = item.ItemAttributes.Title;
            dr[&amp;quot;AuthorName&amp;quot;] = item.ItemAttributes.Author[0];
            dr[&amp;quot;Offer&amp;quot;] = item.Offers.Offer;
            dr[&amp;quot;ASIN&amp;quot;] = item.ASIN;
            dr[&amp;quot;Currency&amp;quot;] = item.ItemAttributes.ListPrice.CurrencyCode;
            dr[&amp;quot;URL&amp;quot;] = item.DetailPageURL;
            
            ds.Tables[0].Rows.Add(dr);
        }

        //add the dataset to the cache 
        Cache.Insert(PowerSearchString, ds, null,
            DateTime.Now.AddHours(24), TimeSpan.Zero);

    }
    else
    {
        ds = (DataSet)Cache[PowerSearchString];
    }
    //return the dataset 
    return ds;
}


private ItemSearchResponse grabAmazonSearch(string PowerSearchString)
{
    ItemSearchResponse response;
    AWSECommerceService aws = new AWSECommerceService();
    ItemSearchRequest request = new ItemSearchRequest();
    request.SearchIndex = &amp;quot;Books&amp;quot;;
    request.Power = PowerSearchString;
    request.ResponseGroup = new string[] { &amp;quot;Large&amp;quot; };
    request.Sort = &amp;quot;salesrank&amp;quot;;
    //request.MerchantId = &amp;quot;all&amp;quot;;


    
    
    ItemSearchRequest[] requests = new ItemSearchRequest[] { request };
    ItemSearch itemSearch = new ItemSearch();
    itemSearch.AssociateTag = &amp;quot;myassociatetag-20&amp;quot;;
    itemSearch.SubscriptionId = &amp;quot;AKIAIAAGYTHFJS2RBSVQ&amp;quot;;
    itemSearch.Request = requests;
    response = aws.ItemSearch(itemSearch);

    return response;
}






}

&lt;/pre&gt;&lt;br /&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Amazon Web Services</title><link>http://forums.asp.net/thread/3274654.aspx</link><pubDate>Sat, 04 Jul 2009 12:46:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274654</guid><dc:creator>mattatuni2</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274654.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=12&amp;PostID=3274654</wfw:commentRss><description>&lt;p&gt;Has anyone used Amazon Ecommerce services or Product advertisting API before??&lt;/p&gt;
&lt;p&gt;Matt&lt;/p&gt;</description></item></channel></rss>