Hi,
Can anyone help me how to give an error message when all properties are not assigned when it done? For example, when SQLadapter is used, connnection property isn't assigned to object yet, thus an error message show up. Please, give me some code example.
Thanks,
in the SqlDataAdapter example, in the .fill method there will be a line that checks the connection string is filled in and if it isnt it will throw an exception e.g
private sub fill(byval dt as datatable)
if Connection is nothing then
throw(new Exception("Error connection not specified")
else
'Run code to fetch data.....
end if
end sub
SqlDataAdapter blah = new SqlDataAdapter("asjkdakd", "asldkjsadlkjsa");
SqlConnection conn = new SqlConnection("sdadad");
try { conn.Open(); }
catch (SqlException ex)
{
//put ex in a session to be read, in a label or something
}
catch (Exception ex)
{
//put ex in a session to be read, in a label or something
}
0 comments:
Post a Comment