PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Using SQLConnection in C# to connect to a database
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Using SQLConnection in C# to connect to a database
![]() |
Using SQLConnection in C# to connect to a database |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I have written a very simple test program in C# to connect to a
database. It displays a button. When the user clicks the button it invokes the code below to connect to the database. This works fine in the emulator but I get a SQLException when I run it on the Pocket PC from its cradle. The network connection seems fine because I can use IE to get web pages using the Pocket PC. What is strange about this is that it was working fine 3 days ago when the Pocket PC was in its cradle. Now it doesn't. The only thing that happened between then and now is that I installed MS Office XP. Do you think I should reinstall VS.NET 2003? Anyone else experience this problem? Any thoughts or suggestions are most welcome. David private void button1_Click(object sender, System.EventArgs e) { System.Data.SqlClient.SqlConnection cn = new SqlConnection(); cn.ConnectionString = "myconnectionstring"; try { cn.Open(); if (cn.State == ConnectionState.Open) { MessageBox.Show("Connection is open"); cn.Close(); } } catch (Exception excp) { MessageBox.Show("Exception: " + excp.Message); MessageBox.Show("Base Exception: " + excp.GetBaseException().Message); } } |
|
|
|
#2 |
|
Guest
Posts: n/a
|
I don't know why it changes.
however I notice it's safer to use IP addresss instead of hostname to describe server location... "David cox" <david.cox@us.abb.com> wrote in message news:96d73d12.0403151354.149936a@posting.google.com... > I have written a very simple test program in C# to connect to a > database. It displays a button. When the user clicks the button it > invokes the code below to connect to the database. > > This works fine in the emulator but I get a SQLException when I run it > on the Pocket PC from its cradle. The network connection seems fine > because I can use IE to get web pages using the Pocket PC. What is > strange about this is that it was working fine 3 days ago when the > Pocket PC was in its cradle. Now it doesn't. The only thing that > happened between then and now is that I installed MS Office XP. > > Do you think I should reinstall VS.NET 2003? Anyone else experience > this problem? Any thoughts or suggestions are most welcome. > > David > > private void button1_Click(object sender, System.EventArgs e) > { > System.Data.SqlClient.SqlConnection cn = new SqlConnection(); > > cn.ConnectionString = "myconnectionstring"; > try > { > cn.Open(); > if (cn.State == ConnectionState.Open) > { > MessageBox.Show("Connection is open"); > cn.Close(); > } > } > > catch (Exception excp) > { > MessageBox.Show("Exception: " + excp.Message); > MessageBox.Show("Base Exception: " + > excp.GetBaseException().Message); > } > } |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

