[英]How to connect windows CE c# application to database SQL Server2008r2
Please help. 请帮忙。 I have device MC3200 Zebra(motorola)(Windows Embedded version 7, build 2864).
我有设备MC3200 Zebra(motorola)(Windows Embedded版本7,内部版本2864)。 This device is connecting to network and see SQL server(ping is OK).
该设备正在连接到网络,请参阅SQL Server(ping操作正常)。 I used it Visual Studio 2008, c#, SmartDevicePrj, .NET CF 3.5
我使用了Visual Studio 2008,c#,SmartDevicePrj,.NET CF 3.5
But after start application on device will be displayed message: 但是在设备上启动应用程序后,将显示以下消息:
Unknown connection option in connection string: initial catalog.
连接字符串中的未知连接选项:初始目录。
Some idea how to repair it? 知道如何修复吗?
Many thanks for your help. 非常感谢您的帮助。
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace SmartDeviceProject1
{
public partial class Form1 : Form
{
public SqlCeConnection msConn;
public string strCon = "";
public SqlCeCommand command;
public Form1()
{
InitializeComponent();
strCon = "Data Source=server007; Initial Catalog=FMPredlis; User ID=mistr; Password=heslo;";
try
{
msConn = new SqlCeConnection(strCon);
msConn.Open();
MessageBox.Show("Připojeno");
}
catch (SqlCeException ex)
{
MessageBox.Show("Chyba" + ex.Message);
msConn.Close();
}
}
}
}
I think you are mixing 2 things. 我认为您正在混合两件事。
Either use The SqlConnection object, then you can connect to a SQL Server using a connection string found on this page: https://www.connectionstrings.com/sql-server/ 可以使用SqlConnection对象,然后可以使用在此页面上找到的连接字符串连接到SQL Server: https : //www.connectionstrings.com/sql-server/
Or use like in your code the SqlCEConnection, then you connect to a SQL Lite (local file), and your connection string should be like on this page: https://www.connectionstrings.com/sqlite/ 或在代码中使用SqlCEConnection,然后连接到SQL Lite(本地文件),连接字符串应类似于此页面: https : //www.connectionstrings.com/sqlite/
But in your sample you are using SqlCEConnection to connect to a sql server, that wont work. 但是在您的示例中,您正在使用SqlCEConnection连接到sql服务器,但无法正常工作。
Grtz 格茨
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.