Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2007, 10:22 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fix Error

When i executed this code, i receive :

System.FormatException: Input string was not in a correct format.

Plz, help me to fix this problem.
Thanks.

Sub DeleteSelectedFile_Click(sender As Object, e As EventArgs)
For Each row As GridViewRow In userFileGridView.Rows
Dim cb As CheckBox = row.FindControl("FileSelector")
If cb IsNot Nothing AndAlso cb.Checked Then

Dim strGUID As String = row.Cells(0).text
Dim idGuid as Guid = New Guid(strGUID)
result.Text=DeleteFile(idGuid)
End If
Next
End Sub


Function DeleteFile(ByVal id As System.Guid) As Integer
       Dim connectionString As String = "Server=10.178.2.38;uid=sa;pwd=veryeasy;database=F iles"
        Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)

        Dim queryString As String = "DELETE FROM [Files] WHERE ([Files].[id] = @id)"
       Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)

       sqlCommand.Parameters.Add("@id", System.Data.SqlDbType.UniqueIdentifier).Value = id

        Dim rowsAffected As Integer = 0
        sqlConnection.Open
        Try
            rowsAffected = sqlCommand.ExecuteNonQuery
        Finally
            'sqlConnection.Close
        End Try

        Return rowsAffected
    End Function







Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft SQL isapi extension ERROR - FIX proslambano BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 January 6th, 2007 10:25 AM
How to fix this error massage for the EventLog?? riki_gill ASP.NET 1.x and 2.0 Application Design 0 October 31st, 2006 12:26 AM
how to fix the error : Exception Details: System.D khaink ASP.NET 1.0 and 1.1 Basics 2 October 9th, 2005 12:24 AM
how to fix this Parser Error Message? method ASP.NET 1.0 and 1.1 Basics 0 May 25th, 2005 11:09 AM
Cannot figure out how to fix error in Tomcat 5 Bluelicious Apache Tomcat 1 December 4th, 2004 03:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.