简体   繁体   English

Windows Installer中的sdf数据库连接错误

[英]sdf database connection error in windows installer

I am working on a windows form application in Visual studio 2010 using sdf database .I have created a setup file using the Setup Project in Visual Studio installer. 我正在使用sdf数据库在Visual Studio 2010中的Windows窗体应用程序上工作。我已经使用Visual Studio安装程序中的安装项目创建了安装文件。

My problem is that when I install the application and try to log in using my log in page, There is an error occurring saying there is no row at position 0 . 我的问题是,当我安装应用程序并尝试使用登录页面登录时,发生错误,指出位置0处没有行 I think the application is not connected to database. 我认为应用程序未连接到数据库。

Is there any difference in setup project when we use sdf database? 使用sdf数据库时,安装项目是否有任何区别? Please help me with this. 请帮我解决一下这个。

在此处输入图片说明

It means that no results were returned from your query. 这意味着您的查询未返回任何结果。 You always have to code defensively and check to see if the Rows array has any items in it before trying to index into it. 您始终必须进行防御性编码,并在尝试索引到Rows数组之前检查其中是否有任何项目。 Something like: 就像是:

if (dt.Rows.Length > 0)
   DoSomething();
else
    somethingWentWrong();

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM