Remote Data Acces RDA not allowed in csharp smart device,????
-
Hi, I try to develop a csharp smart device application.I want to try the RDA method to connect to the database .mdf located in my collegue'sPC My code is like that:
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=Bacem-PC;User ID=sa;Password=sa;Initial Catalog=GMAO;Persist Security Info=false;"; string sSQL = "SELECT Nbt FROM 4BT; "; SqlConnection conn = new SqlConnection(sConnection); SqlCommand comm = new SqlCommand(sSQL, conn); SqlDataReader dr = null; try { comm.Connection.Open(); dr = comm.ExecuteReader(); while (dr.Read()) comboBox1.Items.Add(dr\[0\]); } catch (SqlException ex) { MessageBox.Show("connexion impossible"); MessageBox.Show(ex.Message); return; } dr.Close(); comm.Connection.Close(); } }
}
where bacem-PC is my freind'sPC server .He enables remote connexion to his sql server. When running,this error appears:"specified sql server not found or acces denied" As a note,this is the same arror that appears when I try locally in my PC I am really fed up of this annoying error?? URGENT HELP I NEED or i will be a mad person :-O Thanks
-
Hi, I try to develop a csharp smart device application.I want to try the RDA method to connect to the database .mdf located in my collegue'sPC My code is like that:
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=Bacem-PC;User ID=sa;Password=sa;Initial Catalog=GMAO;Persist Security Info=false;"; string sSQL = "SELECT Nbt FROM 4BT; "; SqlConnection conn = new SqlConnection(sConnection); SqlCommand comm = new SqlCommand(sSQL, conn); SqlDataReader dr = null; try { comm.Connection.Open(); dr = comm.ExecuteReader(); while (dr.Read()) comboBox1.Items.Add(dr\[0\]); } catch (SqlException ex) { MessageBox.Show("connexion impossible"); MessageBox.Show(ex.Message); return; } dr.Close(); comm.Connection.Close(); } }
}
where bacem-PC is my freind'sPC server .He enables remote connexion to his sql server. When running,this error appears:"specified sql server not found or acces denied" As a note,this is the same arror that appears when I try locally in my PC I am really fed up of this annoying error?? URGENT HELP I NEED or i will be a mad person :-O Thanks
Funny thing... :) Afther a whole thread in which I tried to solve your problem but did not succed you are not demoralised and still prospecting for new solutions... I like your persistence :-D You previously said that Visual Studio and Management Studio can connect to your database. If so: add a dataset to your project, and from Visual Studio's datasources (usualy in the left of the screen) drag your tables onto the dataset. This will generate code that connects to your database retrives rows and can update them. (If you don't know how to use this google for
Dataset
andStrongly Typed Dataset
).I have no smart signature yet...
-
Funny thing... :) Afther a whole thread in which I tried to solve your problem but did not succed you are not demoralised and still prospecting for new solutions... I like your persistence :-D You previously said that Visual Studio and Management Studio can connect to your database. If so: add a dataset to your project, and from Visual Studio's datasources (usualy in the left of the screen) drag your tables onto the dataset. This will generate code that connects to your database retrives rows and can update them. (If you don't know how to use this google for
Dataset
andStrongly Typed Dataset
).I have no smart signature yet...
Hi Vlad, :laugh: When I have a problem,I don't be happy only if I solve it with all kinds of problems The problem,Vlad,is that the database I want to connect to is is .mdf database and not .sdf file(used in mobile applications).I want to clarify to u that my project has an object to help the technician communicates successfully with his society'sdatabase.In fact,This society has a .mdf databse created with sql server.The technician will communicate with it with his PDA or his mobile.So that is why I try to connect to my freind'sPC server simulating the process I described above. If i will add a dataset like u said,I really don't understand to drag tables of .mdf database and use them like .sdf one because in visual studio smart device application doesn't accept only .sdf database files. I seem sometimes very curious :laugh: but really I want to demonstrate to all that Marwen can deal well very diffucult problems :laugh: Thanks for u collaboration. ;)
-
Hi Vlad, :laugh: When I have a problem,I don't be happy only if I solve it with all kinds of problems The problem,Vlad,is that the database I want to connect to is is .mdf database and not .sdf file(used in mobile applications).I want to clarify to u that my project has an object to help the technician communicates successfully with his society'sdatabase.In fact,This society has a .mdf databse created with sql server.The technician will communicate with it with his PDA or his mobile.So that is why I try to connect to my freind'sPC server simulating the process I described above. If i will add a dataset like u said,I really don't understand to drag tables of .mdf database and use them like .sdf one because in visual studio smart device application doesn't accept only .sdf database files. I seem sometimes very curious :laugh: but really I want to demonstrate to all that Marwen can deal well very diffucult problems :laugh: Thanks for u collaboration. ;)
-
Hi, Thanks I check the link but almost for the steps I did.But nothing is new :(( I need really urgent help :( Thanks
-
Funny thing... :) Afther a whole thread in which I tried to solve your problem but did not succed you are not demoralised and still prospecting for new solutions... I like your persistence :-D You previously said that Visual Studio and Management Studio can connect to your database. If so: add a dataset to your project, and from Visual Studio's datasources (usualy in the left of the screen) drag your tables onto the dataset. This will generate code that connects to your database retrives rows and can update them. (If you don't know how to use this google for
Dataset
andStrongly Typed Dataset
).I have no smart signature yet...
Hi Vlad, Finally I depass the problem of the connexion to server by the DB File's attachment :laugh: . No exception apperas.Still now the problem of the filling of my combobox .I try with sqldataset instead of the sqlreader like this:
string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
string sSQL = "SELECT com FROM energie; ";
SqlConnection conn = new SqlConnection(sConnection);
SqlCommand comm = new SqlCommand(sSQL, conn);
DataSet ds = new DataSet();
SqlCeDataAdapter da = new SqlCeDataAdapter();
SqlDataReader dr = null;
try
{comm.Connection.Open(); da.Fill(ds, "SQL Temp Table"); foreach(DataRow d in ds.Tables\[0\].Rows) comboBox1.Items.Add(d.ToString());
}
catch (SqlException ex)
{
//MessageBox.Show("connexion impossible");
MessageBox.Show(ex.Message);
return;
}dr.Close();
comm.Connection.Close();
}but nothing is added to my combobox. Thanks in all cases for u collaboration :laugh: I am really so happy