小编Nic*_*ick的帖子

如何从c#连接到SQLite db文件?

我正在尝试使用ac#application连接到sqllite数据库.我之前从未使用过SQLLite.

var connectionString = @"data source='C:\TestData\StressData.s3db'";
            connection = new SQLiteConnection(connectionString);
            connection.Open();
Run Code Online (Sandbox Code Playgroud)

当我尝试打开连接时,我得到以下异常:

System.NotSupportedException: The given path's format is not supported.
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

谢谢..

缺口

更新:

我按照建议将"数据源"更改为"DataSource".现在我收到一个新错误:

更改此内容后,我收到一个新错误:System.ArgumentException:Data Source不能为空.使用:memory:在System.Data.SQLite.SQLiteConnection.Open()中打开内存数据库

还有什么建议吗?

c# database sqlite ado.net connection-string

11
推荐指数
1
解决办法
4万
查看次数

为什么我在路线匹配时得到404?ASP.Net MVC

我已经被困在这个问题上几个小时了.

我有一个名为'DecisionPoint'的控制器,我在它的'ApplicationState'动作上设置了一个断点.无论我尝试什么,我都会在浏览器中获得404.我怀疑我的路线不正确所以我下载了一个路由调试器,它将我正在尝试的URL与Controller和动作相匹配.那么为什么我会得到一个404并且永远不会看到断点?

/ DecisionPoint/ApplicationState/no/worky - > 404

控制器:

 public ActionResult ApplicationState(string fileName, string stateString)
        {
            string filePath = GetDpFilePath(fileName);
            HtmlDocument htmlDocument = new HtmlDocument();
            htmlDocument.Load(filePath);
            HtmlNode stateScriptNode =
                htmlDocument.DocumentNode.SelectSingleNode("/html/head/script[@id ='applicationState']");
            stateScriptNode.InnerHtml = "var applicationStateJSON =" + stateString;
            htmlDocument.Save(filePath);

            return Json("State Updated");
Run Code Online (Sandbox Code Playgroud)

路线

 routes.MapRoute(
        "DecisionPointState", // Route name
        "DecisionPoint/ApplicationState/{fileName}/{stateString}", // URL with parameters
        new {controller = "DecisionPoint", action = "ApplicationState"} // Parameter defaults
    );


        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc asp.net-mvc-routing

11
推荐指数
3
解决办法
2万
查看次数

如何在python中调试缩进错误

我正在尝试编写我的第一个python脚本.这是有效的,但经过一些轻微的重构,我显然已经打破了缩进.我无法确定是什么问题.口译员抱怨以下方法.有人能说出来吗?

def dataReceived(self, data):
    a = data.split(':')
    print a
    if len(a) > 1:
        command = a[0]
        content = a[1]

        msg = ""
        if command == "iam":
            self.name = content
            msg = self.name + " has joined"

        elif command == "msg":
            msg = self.name + ": " + content
            print msg
Run Code Online (Sandbox Code Playgroud)

错误读取:文件"python_server.py",第17行a = data.split(':')^ IndentationError:预期缩进块

python debugging indentation

11
推荐指数
2
解决办法
1万
查看次数

如何从控制台应用程序中访问"属性"命名空间?

我试图存储/检索存储在应用程序设置中的值.从我的控制台应用程序中,我似乎无法访问Properties.Setting命名空间.我的网上冲浪显示,在控制台应用程序中可能需要做更多的工作.怎么做到这一点?

string test = Properties.Settings.Default.MyString;
Run Code Online (Sandbox Code Playgroud)

谢谢!

.net c# properties global-variables application-settings

10
推荐指数
1
解决办法
2万
查看次数

NHibernate Win Forms会话管理

我以前在Web应用程序中使用过NHibernate.我必须承认,我仍在学习NHibernate,并没有完全掌握会话管理的艺术.所以我想在我写的Win Forms应用程序中使用NHibernate.我听说Forms应用程序中的会话管理有点不同.必须在会话的基础上打开和关闭会话.是?有谁知道这个好例子?或者也许是一些有用的文档解释会话创建和在win32应用程序中拆除?

谢谢,

缺口

data-binding nhibernate winforms

9
推荐指数
2
解决办法
5265
查看次数

ConfigurationManager不断获取Machine.config连接字符串

我有一个ac#assembly,它使用app.config来存储它的数据库连接字符串.在调试应用程序时,我注意到与数据库的连接保持失败,因为ConfigurationManager保持返回machine.config连接字符串:

data source =.\ SQLEXPRESS; 综合安全; ....

<clear/在app.config中的连接字符串之前添加了>,它修复了我的开发机器上的问题.我将其部署到生产环境时返回了问题.有人能告诉我如何停止使用machine.config连接字符串吗?

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[0].ConnectionString);

<connectionStrings>
    <clear/>
    <add name="VersionConnectionString"
     connectionString=" Data Source=localhost;Initial Catalog=VersionInfo;User ID=user;Password=password"         
     providerName="System.Data.SqlClient" />
  </connectionStrings>
Run Code Online (Sandbox Code Playgroud)

UPDATE

以下仍然给我machine.config连接字符串?!

 Configuration appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
                string dllConfigData =
                    appConfig.ConnectionStrings.ConnectionStrings[0].ConnectionString;
Run Code Online (Sandbox Code Playgroud)

c# configuration configurationmanager

9
推荐指数
2
解决办法
5510
查看次数

IOS Facebook SDK 4.01:我应该使用FBSDKAccessToken.currentAccessToken()来检查用户是否已登录?

我试图熟悉FB最新的IOS SDK(4.0.1).我已将它集成到IOS8 Swift项目中,并使用FBSDKLoginButton来记录和退出用户.我希望应用程序在用户已经登录时跳过显示Login视图控制器.

我应该只检查FBSDKAccessToken currentAccessToken()的返回结果吗?如果用户没有登录,这会返回'nil'吗?文档有关于此方法的以下内容:

您可以在应用程序冷启动时从钥匙串缓存或应用程序书签加载SDK.您应该在视图控制器的viewDidLoad中检查其可用性.

就像是:

// LoginViewController.swift     
override func viewDidLoad() {
        super.viewDidLoad()
        if(FBSDKAccessToken.currentAccessToken()){
            //They are logged in so show another view
        }else{
            //They need to log in
        }
    }
Run Code Online (Sandbox Code Playgroud)

因此,这听起来像它可能是什么我要找的,但我真的不能从这个描述出来.SO的优秀人员如何处理这个常见用例?:)

-缺口

facebook-ios-sdk swift ios8

9
推荐指数
1
解决办法
6508
查看次数

JQuery将单击事件添加到无线电输入文本

我希望标签与单选按钮"热"相关联.我开始使用.siblings()方法实现它.我认为必须有更好的方法.单选按钮上的单击事件如下所示:

$(".RadioButton").click(function(event) {

        var questionId = $(this).find('input').attr('name');
        var responseId = $(this).find('input').attr('value');
        var answerText = displayPopupQuizAnswer($(this));
Run Code Online (Sandbox Code Playgroud)

这非常有效.我希望当用户点击单选按钮旁边的文本标签时执行相同的代码.html看起来像这样:

<div class="answers">
<span class="radiobutton>
<input type="radio" name="answer1"/>
</span>
<span class="answertextwrapper">
<a href="return false">this is the text</a>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)

这是简化但很接近.我想要的是用class ="answertextwrapper"捕获元素上的click事件,即$(".answerwrapper").click

因此,我需要在单击文本时以某种方式引用输入.合理?

有任何想法吗?

html javascript jquery

8
推荐指数
2
解决办法
4万
查看次数

加载了"ChatView"笔尖,但没有得到UITableView.

我有一个自定义的UITableViewController("ChatView"),它有一个tableView的输出.在界面构建器中,我已将笔尖中的tableView连接到插座.当视图加载时,我得到上述错误.视图通过tabcontroller加载.

我已经对错误做了一些研究,我似乎无法追查这个问题.如果有人能让我朝着正确的方向努力解决这个问题,我将不胜感激.

@interface ChatViewController : UITableViewController
<UITableViewDelegate, UITableViewDataSource> {

    NSMutableArray *chatMessages;
    IBOutlet UITableView *chatTable;
    IBOutlet UITextField *chatText;


}

@property(nonatomic, retain) IBOutlet UITextField *chatText;
@property (nonatomic, retain) IBOutlet  UITableView *chatTable;
@property (nonatomic, retain) NSMutableArray *chatMessages;


-(IBAction)sendPressed;


@end
Run Code Online (Sandbox Code Playgroud)

谢谢

cocoa-touch objective-c

8
推荐指数
3
解决办法
8898
查看次数

我可以在目录和子目录中搜索头文件吗?

有可能指示g ++以递归方式搜索头文件的文件夹吗?在我的例子中,我想要g ++来搜索

/ ARDrone_SDK_2_0_1/ARDroneLib /柔和/

以及头文件的所有子目录.可以这样做吗?这是一个简单的Makefile例子:

C=g++
CFLAGS=-c -Wall
LDFLAGS=
INC1=/ARDrone_SDK_2_0_1/ARDroneLib/Soft/ <- can this be recursive?
INCDIRS= -I${INC1}
SOURCES=src/dronevid.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=build/dronevid

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS) 
    $(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
    $(CC) $(CFLAGS) $(INCDIRS) $< -o $@
Run Code Online (Sandbox Code Playgroud)

c c++ gcc makefile

8
推荐指数
1
解决办法
9404
查看次数