doubt about namespace google

  • Thread starter manasa sreenivas via .NET 247
  • Start date
M

manasa sreenivas via .NET 247

Respected Sir ,
while compiling c sharp code, getting an error as google namespace is not found.

please send me the solution for this as soon as possible.

Code :

using System.IO;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.Threading;

namespace AGS
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList DropDownDisplay;
protected System.Web.UI.WebControls.TextBox SearchBox;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.Label Label1;

private void Page_Load(object sender, System.EventArgs e)
{
Label1.Visible=false;
if (!Page.IsPostBack)
{
DropDownDisplay.Items.Add("Broad Match");
DropDownDisplay.Items.Add("Phrase Match");
DropDownDisplay.Items.Add("Exact Match");
DropDownDisplay.Items.Add("Negative Match");
}

// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.DataList1.ItemCreated += new System.Web.UI.WebControls.DataListItemEventHandler(this.DataList1_ItemCreated);
this.DataList1.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.DataList1_ItemCommand);
this.DataList1.UpdateCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.DataList1_UpdateCommand);
this.DataList1.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.DataList1_ItemDataBound);
this.DataList1.SelectedIndexChanged += new System.EventHandler(this.DataList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion



private void Button1_Click(object sender, System.EventArgs e)
{

string Broad = SearchBox.Text;
string Phrase=" ' " + SearchBox.Text + " ' ";
string Exact=" [ " + SearchBox.Text + " ] " ;
string Negative= "red" + SearchBox.Text;
string LicenseNo="l7QDmvZQFHJW+U9glNGa89dsNZ4LpdpQ";
//"g5w/xPRQFHJ019W86jdUFrsxpfQB4RNP";
string OptionSelected;
if (DropDownDisplay.SelectedItem.Text=="Broad Match")
OptionSelected=Broad;
else if (DropDownDisplay.SelectedItem.Text=="Phrase Match")
OptionSelected=Phrase;
else if (DropDownDisplay.SelectedItem.Text=="Exact Match")
OptionSelected=Broad;
else if (DropDownDisplay.SelectedItem.Text=="Negative Match")
OptionSelected=Negative;
DataTable dt=new DataTable();
DataRow dr;
dt.Columns.Add((new DataColumn("List",typeof(string))));




try
{
Google.GoogleSearchService s = new Google.GoogleSearchService();
Google.GoogleSearchResult r = s.doGoogleSearch(LicenseNo, SearchBox.Text,0, 10, false, "", false, "", "", "");
int Results = r.estimatedTotalResultsCount;
Label1.Visible=true;
Label1.Text = "Results Obtained for: " + SearchBox.Text +" are : "+Convert.ToString(Results);
foreach (Google.ResultElement rs in r.resultElements)
{
dr=dt.NewRow();
dr[0]=rs.URL;
dt.Rows.Add(dr);

//DropDownResultDisplay.Items.Add(rs.URL);
}
DataList1.DataSource=new DataView(dt);
DataList1.DataBind();

}
catch (System.Web.Services.Protocols.SoapException ex)
{
//Response.Redirect(DropDownResultDisplay.SelectedItem.ToString());
}
}

private void DataList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//Response.Redirect(DataList1.DataKeys[DataList1.SelectedIndex].ToString());
}

private void DataList1_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
//Response.Redirect(DataList1.DataKeys[DataList1.SelectedIndex].ToString());
}

private void DataList1_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{

}

private void DataList1_UpdateCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{

}

private void DataList1_ItemCreated(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{

}
}

}
 
J

John Young

Have you referenced the Google assembly (if there is one), or are you
missing a Using statement?

--
===============================
try
{
Linux (any version)
}
catch
{
Format (mainHardDisk)
Install (Windows2000/XP/2003)
}
// You know you want to !!!

John Young
manasa sreenivas via .NET 247 said:
Respected Sir ,
while compiling c sharp code, getting an error as google
namespace is not found.

please send me the solution for this as soon as possible.

Code :

using System.IO;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.Threading;

namespace AGS
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList DropDownDisplay;
protected System.Web.UI.WebControls.TextBox SearchBox;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.Label Label1;

private void Page_Load(object sender, System.EventArgs e)
{
Label1.Visible=false;
if (!Page.IsPostBack)
{
DropDownDisplay.Items.Add("Broad Match");
DropDownDisplay.Items.Add("Phrase Match");
DropDownDisplay.Items.Add("Exact Match");
DropDownDisplay.Items.Add("Negative Match");
}

// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.DataList1.ItemCreated += new
System.Web.UI.WebControls.DataListItemEventHandler(this.DataList1_ItemCreated);
this.DataList1.ItemCommand += new
System.Web.UI.WebControls.DataListCommandEventHandler(this.DataList1_ItemCommand);
this.DataList1.UpdateCommand += new
System.Web.UI.WebControls.DataListCommandEventHandler(this.DataList1_UpdateCommand);
this.DataList1.ItemDataBound += new
System.Web.UI.WebControls.DataListItemEventHandler(this.DataList1_ItemDataBound);
this.DataList1.SelectedIndexChanged += new
System.EventHandler(this.DataList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion



private void Button1_Click(object sender, System.EventArgs e)
{

string Broad = SearchBox.Text;
string Phrase=" ' " + SearchBox.Text + " ' ";
string Exact=" [ " + SearchBox.Text + " ] " ;
string Negative= "red" + SearchBox.Text;
string LicenseNo="l7QDmvZQFHJW+U9glNGa89dsNZ4LpdpQ";
//"g5w/xPRQFHJ019W86jdUFrsxpfQB4RNP";
string OptionSelected;
if (DropDownDisplay.SelectedItem.Text=="Broad Match")
OptionSelected=Broad;
else if (DropDownDisplay.SelectedItem.Text=="Phrase Match")
OptionSelected=Phrase;
else if (DropDownDisplay.SelectedItem.Text=="Exact Match")
OptionSelected=Broad;
else if (DropDownDisplay.SelectedItem.Text=="Negative Match")
OptionSelected=Negative;
DataTable dt=new DataTable();
DataRow dr;
dt.Columns.Add((new DataColumn("List",typeof(string))));




try
{
Google.GoogleSearchService s = new Google.GoogleSearchService();
Google.GoogleSearchResult r = s.doGoogleSearch(LicenseNo,
SearchBox.Text,0, 10, false, "", false, "", "", "");
int Results = r.estimatedTotalResultsCount;
Label1.Visible=true;
Label1.Text = "Results Obtained for: " + SearchBox.Text +" are :
"+Convert.ToString(Results);
foreach (Google.ResultElement rs in r.resultElements)
{
dr=dt.NewRow();
dr[0]=rs.URL;
dt.Rows.Add(dr);

//DropDownResultDisplay.Items.Add(rs.URL);
}
DataList1.DataSource=new DataView(dt);
DataList1.DataBind();

}
catch (System.Web.Services.Protocols.SoapException ex)
{
//Response.Redirect(DropDownResultDisplay.SelectedItem.ToString());
}
}

private void DataList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
//Response.Redirect(DataList1.DataKeys[DataList1.SelectedIndex].ToString());
}

private void DataList1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
//Response.Redirect(DataList1.DataKeys[DataList1.SelectedIndex].ToString());
}

private void DataList1_ItemCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{

}

private void DataList1_UpdateCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{

}

private void DataList1_ItemCreated(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{

}
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top