-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: DotNetHunk
Message 1 in Discussion

hi all!!im back with a new problem(ive been fighting with it for 4 hours 
now).lot of googling lead to lot of confusion!!

in a webform,there is a textbox which will take date as input and a submit 
button which will update the date to sql server database.
the real problem is,im using ado.net disconnected model.when i debug the app,it 
throws with the following error.im pasting the code and the error returned.pl 
help me out!
CODE::
Imports System.data
Imports System.Data.sqlclient

Public Class WebForm1
    Inherits System.Web.UI.Page
    Dim conn As New SqlConnection
    Dim da As SqlDataAdapter
    Dim ds As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim strconnection As String = "data source=localhost;user 
id=sa;password=;initial catalog=example"
        conn = New SqlConnection(strconnection)
        conn.Open()
        Dim strselect As String = "select * from datadata"
        da = New SqlDataAdapter(strselect, conn)
        Dim autogen As New SqlCommandBuilder(da)
        ds = New DataSet
        da.Fill(ds, "datadata")
        Dim dt As DataTable = ds.Tables("datadata")
        Dim row As DataRow = dt.NewRow()
        row("engdata") = Convert.ToDateTime(txtDate.Text)
        dt.Rows.Add(row)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles Button1.Click
        da.Update(ds, "datadata")
        conn.Close()
    End Sub
End Class

ERROR RETURNED::
String was not recognized as a valid DateTime. 
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.FormatException: String was not recognized as a valid 
DateTime.

Source Error: 


Line 42:         Dim dt As DataTable = ds.Tables("datadata")
Line 43:         Dim row As DataRow = dt.NewRow()
Line 44:         row("engdata") = Convert.ToDateTime(txtDate.Text)
Line 45:         dt.Rows.Add(row)
Line 46: 
 

Source File: c:\inetpub\wwwroot\datedate\WebForm1.aspx.vb    Line: 44 

Stack Trace: 


[FormatException: String was not recognized as a valid DateTime.]
   System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles 
styles) +919
   System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles 
styles) +30
   System.DateTime.Parse(String s, IFormatProvider provider) +11
   System.DateTime.Parse(String s) +7
   System.Convert.ToDateTime(String value) +46
   datedate.WebForm1.Page_Load(Object sender, EventArgs e) in 
c:\inetpub\wwwroot\datedate\WebForm1.aspx.vb:44
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()

 


-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to