2013-07-17 135 views
0

我已經在正在使用的通訊端口傳送數據,保存一個訪問2010數據庫,然後將這些數據傳送到SQL服務器vb.net寫了一個程序。該計劃需要每年365天,每天24小時運行。如果服務器出現故障或網絡拔出,則仍需要在本地運行並保存數據。停止錯誤信息出現

所以這是我的問題。當我執行程序時,拔掉網線,我明顯得到了錯誤信息,但是我需要錯誤信息才能中斷程序,我只想要一個彈出框。

任何幫助將大大appriciated。我不確定發佈代碼的內容,看看有多少。

+1

這不是什麼異常處理是什麼? http://support.microsoft.com/kb/315965 –

+0

你熟悉''Try'和Catch''Finally'? –

+1

是 - 處理異常並做適當的事情。比如寫一個日誌文件。 – Randy

回答

1

使用try語句這將是最簡單的方法。

Try 

'run what ever code you need here 

Catch ex As Exception 

'when your network goes down the function that is called to interact with the web will trigger this. 
'so you can save your stuff at this part 

Finally 

'after everything is done you can do what ever you want here. 

End Try