Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Protected Sub DataList1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.UpdateCommand
        Dim AgentId As String = DataList1.DataKeys(e.Item.ItemIndex).ToString()
        DataList1.DataKeys(e.Item.ItemIndex).ToString()
        Dim Name As TextBox = CType(e.Item.FindControl("txtName"), TextBox)
        str = ""
        Try
            openConnection(con)
            
            str = "UPDATE Agent_Master SET A_Name='" & Name.Text & "'WHERE AgentId ='" & AgentId & "'"

            cmd = New OleDbCommand(str, con)

            cmd.ExecuteNonQuery()

            LoadData()
            DataList1.EditItemIndex = -1

        Catch ex As Exception
            alert(MessageType.Fail)
        Finally
            con.Close()
        End Try
        
    End Sub



in he above program control goes to exception block when it passes the openConnection(con).what will i do ?
Posted
Updated 23-Sep-11 20:20pm
v2
Comments
Mehdi Gholam 24-Sep-11 2:21am    
What is the exception?

1 solution

Probably your connection string is invalid or a connection can't be established. Check your connection string and make sure that you sql server is available.

Cheers
 
Share this answer
 
Comments
Member 8224164 24-Sep-11 2:43am    
you are right.
Mario Majčica 24-Sep-11 2:51am    
Great than click on accept the solution so we can close this thread ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900