Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Connecting to SQL Server from Windows CE

0 views
Skip to first unread message

Bruno Sena

unread,
Dec 8, 2009, 8:52:02 AM12/8/09
to
Hi,

I need to connect to SQL Server 2005 from Windows CE 5.0.
My code is the following:

SqlConnection conexao = new SqlConnection();
try
{

string strConn = "Data Source=192.168.73.149,1433;Initial
Catalog=Amend;user id=sa;password=Trix2009!;";

conexao.ConnectionString = strConn;
conexao.Open();

string query = "SELECT * FROM Produto";

SqlCommand comando = new SqlCommand(query);
SqlDataReader reader = comando.ExecuteReader();
while (reader.Read())
{
MessageBox.Show(reader["Produto"].ToString());
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conexao.Close();
}

It throws an exception telling just SQLException.
I don't know what occurs.

Thanks.

Paul G. Tobey [ eMVP ]

unread,
Dec 8, 2009, 10:42:01 AM12/8/09
to
There's always more information that that. Look at the exception object. It
might have an innerException which actually holds the details, etc., but you
should be able to get more from the occurrence than what you've taken away so
far. Which call throws the exception, for example? That, by itself, will
tell you something! I don't suppose that there's a firewall between you and
the PC where SQL Server is running?

Paul T.

0 new messages