win32服务程序 用ado ole连接SQLServer 有经验的朋友帮忙来处理一下

罗捷捷 2018-02-01 02:41:26
很纠结 处理几天了 具体情况是这样的
一个Win32服务项目 用了ado ole驱动连SQLServer
因为是做的随系统启动服务
每次重启机器后 服务没成功启动就崩溃了
日志提示启动的时候SQLServer还没启动 无法找到SQLServer服务
然后我把服务依赖MSSQL服务启动
就会提示用户'xxxx'登录失败 但是这个密码绝对是没问题的 因为我手动启动是没有错误的 换了sa账户也是这样的错误
然后我试着让服务启动等待10秒 再连接 这个是可以了 但是我觉得不是个最终解决方案
所以来问问大神 有能处理的不
...全文
684 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
www_adintr_com 2018-02-22
  • 打赏
  • 举报
回复
捕获一下链接数据库时出现的错误, 如果出现错误, 延迟几百毫秒后再重试
罗捷捷 2018-02-18
  • 打赏
  • 举报
回复
不好意思 处理晚了 大家新年好 回复#1 依赖有效果了 会在MSSQL之后启动我的服务 但是出现的错误莫名其妙 会提示用户'xxxx'登录失败 回复#2 我不会用调试器 就是不清楚为什么会这样 我用Sleep(10000) 多等待几秒再连SQL就没事
赵4老师 2018-02-05
  • 打赏
  • 举报
回复
用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe. Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example, c:\Debuggers\windbg.exe In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop. This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours. 设置ServicesPipeTimeout后需要重启系统才生效 Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.) If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.
donjin9 2018-02-02
  • 打赏
  • 举报
回复
CreateService里的依赖服务设置不起作用吗?
基于VB6自主研发的轻量级数据库查询客户端工具,启动速度较快,所占资源较小。 附源码,对初学数据库编程的童鞋有所裨益! 1、支持SQLServer、Oracle、Sybase、DB2数据库平台 2、单句执行:可以提交单一的SQL语句给服务器执行。 3、多句一次执行:可以将多个SQL语句用空格或换行的方式进行隔离,程序会一次性提交给数据库服务器执行。(前提条件是语法通过) 4、多句依次执行:可以将多个SQL语句用分号‘;’隔开,程序会逐句提交。 5、执行指定的SQL语句:可以在SQL编辑框中选中部分语句执行,在SQL命令框中通过鼠标连续单击3次可以选择当前行。 6、在事务中执行SQL语句:将执行按钮上方的Trans 框选中,那么程序对于每次提交的SQL语句都是放在事务中执行的,执行不成功程序会进行回滚操作。程序默认不进行事务处理,因为有些语句不能在事务中执行。 版本修订记录: V3.6.0 16:08 2012/6/18 --支持DB2数据库平台,要求客户端安装 DB2 Run-Time Client Lite。 --支持数据库名的记忆功能。 V3.5.11 14:36 2012-5-12 --支持连接非缺省端口号的SQL Server平台。 V3.5.10 8:54 2009/12/22 --将OUT标签更名为Output。 V3.5.9 10:48 2009/8/19 --修订Bug:在Vista或Win7系统下主界面部分被遮盖显示不全的问题。 V3.5.8 --修订Bug:执行的存储过程没有返回结果集,在导出Excel时出现运行时错误。 V3.5.7 --界面标题栏增加当前连接数据库信息。 --修订死循环Bug,死3次后退出执行。 --修订最末语句分号后面跟若干回车符执行死循环的Bug。 V3.5.6 --还是使用TextBox控件作为SQL命令的输入框,RichTextBox控件的滚动条功能不太好用; --使用字符算法实现了双击SQL命令框选中当前行的功能(TextBox控件本身不支持)。 --修订了窗体在Resize时的Bug。 V3.5.5 --使用RichTextBox控件代替原有的TextBox控件SQL命令输入框(支持双击选中整行功能)。 --使用‘;’和‘回车换行’符号联合作为SQL命令逐个提交的分割标志符。 V3.5.4 --修订SQL日志文件记录错误的Bug。 V3.5.3 --修订系统未安装任何打印机的情况下导出Excel失败的Bug(设置打印页面横向时失败)。 V3.5.2 --修订运行目录没有可写权限导致记录日志失败无法提交SQL语句的Bug。 V3.5.0 --新增记录SQL语句日志的功能。 V3.4.0 --新增导出查询结果集到Excel文档的功能。 V3.3.4 --修改了窗体内部控件自动放缩的控制算法; --修改数据显示窗口支持滚轮鼠标的上下左右翻滚操作。 V3.3.0 --修改了连接ORACLE的连接字符串,要求客户端安装ODAC组件(OLEDB); --数据库下拉列表默认上次选择的数据项。 V2.0.0 --支持Sybase平台,要求客户端安装Sybase OLEDB组件; V1.0.0 --支持SQL Server平台,安装包中自带ADO组件。

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧