When I run this file I get the following error:
Server Error in '/' Application.
Value cannot be null. Parameter name: input Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: input
Source Error:
Line 43: dr["Assignee"] = result.Assignee;
Line 44: dr["PatentNumber"] = result.PatentNumber;
Line 45: dr["Date"] = DateTime.Parse(result.ApplicationDate.ToString()).ToString("dd MMM yyyy");
Line 46: dt.Rows.Add(dr);
Line 47: }
Source File: d:\dzhosts\localuser\kareem\www.kareem2.somee.com\GooglePatentSearch.aspx.cs Line: 45
Stack Trace:
[ArgumentNullException: Value cannot be null. Parameter name: input]
System.Text.RegularExpressions.Regex.Replace(String input, String replacement) +6402895
System.Text.RegularExpressions.Regex.Replace(String input, String pattern, String replacement) +88
Google.API.Search.SearchUtility.RFC2822DateTimeParse(String str) +50
Google.API.Search.GpatentResult.Google.API.Search.IPatentResult.get_ApplicationDate() +12 GooglepatentSearch.Button1_Click(Object sender, EventArgs e) in d:\dzhosts\localuser\kareem\www.kareem2.somee.com\GooglePatentSearch.aspx.cs:45 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9615678
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
How I can solve this problem?!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Google.API.Search;
public partial class GooglepatentSearch : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dlSearch.DataSource = null;
dlSearch.DataBind();
TextBox1.Text = "";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Title", typeof(string)));
dt.Columns.Add(new DataColumn("Url", typeof(string)));
dt.Columns.Add(new DataColumn("Image", typeof(string)));
dt.Columns.Add(new DataColumn("Status", typeof(string)));
dt.Columns.Add(new DataColumn("Content", typeof(string)));
dt.Columns.Add(new DataColumn("Assignee", typeof(string)));
dt.Columns.Add(new DataColumn("PatentNumber", typeof(string)));
dt.Columns.Add(new DataColumn("Date", typeof(string)));
GpatentSearchClient client = new GpatentSearchClient("www.c-sharpcorner.com");
IList<IPatentResult> results = client.Search(TextBox1.Text, 30);
foreach (IPatentResult result in results)
{
DataRow dr = dt.NewRow();
dr["Title"] = result.Title.ToString();
dr["Url"] = result.Url;
dr["Image"] = result.TbImage;
dr["Status"] = result.PatentStatus;
dr["Content"] = result.Content;
dr["Assignee"] = result.Assignee;
dr["PatentNumber"] = result.PatentNumber;
dr["Date"] = DateTime.Parse(result.ApplicationDate.ToString()).ToString("dd MMM yyyy");
dt.Rows.Add(dr);
}
dlSearch.DataSource = dt;
dlSearch.DataBind();
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GooglepatentSearch.aspx.cs" Inherits="GooglepatentSearch" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="300px"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Google Patent Search" OnClick="Button1_Click" />
<br />
<asp:DataList ID="dlSearch" runat="server" Width="600px">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%#Eval("Title")+"("+Eval("Assignee")+")" %>' PostBackUrl='<%#Eval("Url") %>'>
</asp:LinkButton><br />
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Content") %>'>
</asp:Label>
<br />
<img alt="image" src='<%#Eval("Image") %>' />
<br />
<asp:Label ID="Label2" runat="server" Text='<%# "(Status:-"+Eval("Status")+", Patent Number:-"+Eval("PatentNumber")+",Application Date:-"+Eval("Date") +")"%>'>
</asp:Label>
<br />
</ItemTemplate>
<FooterTemplate>
<asp:Label Visible='<%#bool.Parse((dlSearch.Items.Count==0).ToString())%>' runat="server" ID="lblNoRecord" Text="No Record Found!">
</asp:Label>
</FooterTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
Source for this code: http://www.c-sharpcorner.com/UploadFile/29d7e0/google-patent-search-in-Asp-Net/