المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : TCP/IP connexion failed in csharp smart device



C# Programming
05-05-2010, 02:20 PM
Hi,
I develop a GMAO csharp smart device application.I try now to connect to my remote database.mdf using TCP/IP protocol.I created a combobox where i want to extract informations from my table using this select statement:"SELECT DISTINCT NObt FROM 4BT ";.For my IPadreess of my computer,I use the ipconfig/all command and I take the IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred)My hole code is like this:
using System;
using System.Linq;
using System.Data.SqlServerCe;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ModeDifféré
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void Form6_Load(object sender, EventArgs e)
{
string sConnection = "Data Source=192.168.1.4,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";
string sSQL = "SELECT DISTINCT NObt FROM 4BT";
SqlCeCommand comm = new SqlCeCommand(sSQL, new SqlCeConnection(sConnection));
SqlCeDataReader dr = null;
try {
comm.Connection.Open();
dr = comm.ExecuteReader();
while (dr.Read())
comboBox1.Items.Add(dr[0]);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
dr.Close();
comm.Connection.Close();
}
}
}When running,this error appears:
Unknown connection option in connection string: initial catalog.As an information,I follow the steps of this link:http://netcf2.blogspot.com/2005/12/accessing-sql-server-express-from.html[
target="_blank" title="New Window">^ (http://netcf2.blogspot.com/2005/12/accessing-sql-server-express-from.html)]
What is the problem???
Thank u for all u suggestion
Regards
Marwen http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif