简体   繁体   English

如何将Windows CE c#应用程序连接到数据库SQL Server2008r2

[英]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.

相关问题 如何从C#连接到SQL Server Ce数据库? - How to connect to SQL Server Ce database from C#? SQL Server 2008 R2数据库备份和还原功能,通过C#Windows应用程序 - Sql Server 2008 R2 Database backup and restore functionality by C# Windows Application 如何在C#中将图像从SQL Server 2008 R2检索到Datagridview [Windows应用程序] - How to retrieve image from SQL Server 2008 R2 to Datagridview in C# [Windows Application] 无法从Windows应用程序C#连接到SQL Server数据库 - unable to connect to sql server database from windows application c# 如何授予SQL Server 2008数据库从C#Windows应用程序中的客户端系统插入数据的权限? - How to give the permissions to sql server 2008 database to insert the data from client system in c# windows application? 将SQL Server CE数据库嵌入到C#应用程序中 - Embedding SQL Server CE database into a C# application C#Windows应用程序:使用Windows身份验证连接到远程SQL Server 2008的连接字符串 - C# Windows application: connection string to connect to remote sql server 2008 using windows authentication C#以编程方式连接到SQL Server CE - C# Connect to a SQL server CE programmatically 在C#Windows应用程序中使用MS SQL SERVER 2008 R2 EXPRESS? - Use of MS SQL SERVER 2008 R2 EXPRESS with C# Windows Application? 将SQL Server 2008数据库与C#.net中的提示erp连接 - Connect SQL Server 2008 database with tally erp in c# .net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM