简体   繁体   中英

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). This device is connecting to network and see SQL server(ping is OK). I used it 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/

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/

But in your sample you are using SqlCEConnection to connect to a sql server, that wont work.

Grtz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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