简体   繁体   English

Visual Studio 2010 C#调试MS数据集

[英]Visual studio 2010 C# debugging MS Dataset

I am using MSDatasets to link to a server (on local network), method are as below: 我正在使用MSDatasets链接到服务器(在本地网络上),方法如下:

1) Right click the project -> add new item 1)右键单击项目->添加新项目

2) Select dataset and rename 2)选择数据集并重命名

3) Open server explorer and add new connection to server on local network 3)打开服务器资源管理器并向本地网络上的服务器添加新连接

4) Once connected to the local server, drag tables needed into the datasets 4)连接到本地服务器后,将所需的表拖到数据集中

5) the dataset/ table could be called from classes in the program 5)可以从程序中的类调用数据集/表

Everything worked fine. 一切正常。 But sometimes the server might be down for some reasons, and the program thus fail to connect and prompts a error message "A unhandle win32 exception occurred in program.exe......." and then quits the program itself. 但是有时由于某些原因服务器可能已关闭,因此程序无法连接,并提示错误消息“在program.exe中发生未处理的Win32异常........”,然后退出程序本身。

How can a prompt the user with a more user-friendly message (eg "sorry the server is down, please try again later") when the connection to the server fails? 当与服务器的连接失败时,如何提示用户更多用户友好的消息(例如“对不起服务器已关闭,请稍后重试”)?

Thanks! 谢谢!

The only time a DataSet object really connects to the server is when you call your Adapter's Update() or Fill() functions (assuming you're using typed approach only). 只有当您调用适配器的Update()Fill()函数(假设您仅使用类型化方法)时,DataSet对象才真正连接到服务器。 You could place those pieces inside try/catch blocks to achieve what you want. 您可以将这些片段放置在try / catch块中,以实现所需的功能。

If you are using drag-n-drop from Data Sources window, you should have these lines inside your Form's Load event handler and navigation toolbar's SaveButton_Click (or something like that) event handler. 如果要使用“数据源”窗口中的拖放功能,则应在窗体的Load事件处理程序和导航工具栏的SaveButton_Click (或类似名称)事件处理程序中包含这些行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#Visual Studio 2010无法开始调试 - C# Visual Studio 2010 doesn't start debugging 在Visual Studio C#Express 2010中调试Nunit测试 - Debugging Nunit tests in Visual Studio C# Express 2010 在Visual Studio 2010中调试C ++项目 - Debugging C++ project in Visual Studio 2010 在 C# 中的 Visual Studio(2008 和 2010)上调试时“忽略并继续”可能吗? - “Ignore and continue” while debugging on Visual Studio (2008 & 2010) in C# possible? 在Visual Studio 2010中调试时如何在C#中计算方法执行时间? - How to calculate method execution time in c# while debugging in visual studio 2010? 在调试Visual Studio 2010 MVC C#程序时如何从键盘获得输入? - How do I get input from the keyboard while debugging a Visual Studio 2010 MVC C# program? 使用Visual Studio 2010 C#进行调试时,如何避免进入常用功能? - When debugging using Visual Studio 2010 C#, how to avoid stepping into common functions? 为MS Project 2010开发插件时,如何在Visual Studio C#中为editclear()方法创建事件处理程序? - How to create event handler in Visual Studio C# for editclear() method when developind addin for MS Project 2010? 使用MS Visual Studio 2010在C#中读取Excel文件:如何给出相对路径? - Reading Excel File in C# using MS Visual Studio 2010: How to give Relative Path? C#/ Visual Studio调试示例 - C#/Visual Studio Debugging example
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM