Hi, i get the following error, but i don't understand it.
Server Error in '/e-library' Application.
--------------------------------------------------------------------------------
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
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.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Source Error:
Line 221: SqlDataAdapter1.InsertCommand.Parameters("@Due_Dat e").Value = Borrow_Date.AddDays(14)
Line 222: 'SqlConnection1.Open()
Line 223: SqlDataAdapter1.InsertCommand.ExecuteNonQuery()
Line 224: SqlConnection1.Close()
Line 225: End Sub
Source File: c:\inetpub\wwwroot\e-library\Borrow.aspx.
vb Line: 223
Stack Trace:
[SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.]
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
e_library.Borrow.Loan(String Title_id, String Title) in c:\inetpub\wwwroot\e-library\Borrow.aspx.
vb:223
e_library.Borrow.DataGrid1_ItemCommand(Object source, DataGridCommandEventArgs e) in c:\inetpub\wwwroot\e-library\Borrow.aspx.
vb:147
System.Web.UI.WebControls.DataGrid.OnItemCommand(D ataGridCommandEventArgs e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source, EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source, EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Code:
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
If e.CommandName = "Select" Then 'to select particular title
Dim TitleID, Title As Label
TitleID = e.Item.FindControl("lblTitleID")
Title = e.Item.FindControl("lblTitle")
Dim a As Boolean
a = Search(Title.Text)
If a = True Then
Loan(TitleID.Text, Title.Text)
Panel1.Visible = True
Else
Panel2.Visible = True
End If
End If
End Sub
Protected Function Search(ByVal Title As String) As String
Dim str = "SELECT * FROM [Library] WHERE Title = Title"
Dim dr As SqlDataReader
Dim SqlDataAdapter1 As New SqlDataAdapter
Dim sSQL As New SqlCommand
With sSQL
sSQL.Connection = SqlConnection1
sSQL.Connection.Open()
sSQL.CommandText = str
sSQL.CommandType = CommandType.Text
dr = sSQL.ExecuteReader()
End With
If dr.HasRows Then
While dr.Read
quantity = dr("Quantity")
dr.Close()
If quantity >= 1 Then
Return True
Else
Return False
End If
End While
dr.Close()
End If
End Function
Private Sub Loan(ByVal Title_id As String, ByVal Title As String)
Dim Borrow_Date As DateTime
Dim str1 = "INSERT Into LoanRecord Values (@Borrow_Date, @User_id," _
& "@Title_id, @Title, @Due_Date)"
Dim InsCom As New SqlCommand(str1, SqlConnection1)
SqlDataAdapter1.InsertCommand = InsCom
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@Borrow_Date", SqlDbType.DateTime, 8))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@User_id", SqlDbType.Char, 10))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@Title_id", SqlDbType.Char, 10))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@Title", SqlDbType.VarChar, 100))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@Due_Date", SqlDbType.DateTime, 8))
SqlDataAdapter1.InsertCommand.Parameters("@Borrow_Date").Value = DateTime.Today
SqlDataAdapter1.InsertCommand.Parameters("@User_id").Value = Session("UserID")
SqlDataAdapter1.InsertCommand.Parameters("@Title_id").Value = Title_id
SqlDataAdapter1.InsertCommand.Parameters("@Title").Value = Title
SqlDataAdapter1.InsertCommand.Parameters("@Due_Date").Value = Borrow_Date.AddDays(14)
SqlDataAdapter1.InsertCommand.ExecuteNonQuery()
SqlConnection1.Close()
End Sub
Can somebody help me? Thanks a lot!
Irene