Try Catch
-
hi I am posting code wherein i am populating my datatable from an excel sheet and reading the sheet name through the user input in textBox5. Inspite of wrong value in the textbox my catch code do not execute and instead the default error page is displayed where as the expected routine is that it displays the message in lblmessage so that user corrects the entry. Try query = "SELECT * FROM [" & TextBox5.Text & "$]" 'Create the connection object conn = New OleDb.OleDbConnection(connString) 'Open connection If conn.State = ConnectionState.Closed Then conn.Open() 'Create the command object cmd = New OleDb.OleDbCommand(query, conn) da = New OleDb.OleDbDataAdapter(cmd) ds = New DataSet() da.Fill(ds) Catch ex As Exception lblMessage.Visible = True lblMessage.Text = (ex.ToString()) Finally conn.Close() End Try may i request guidance from experts to understand the above problem thanks in advance kris