mono SQL Server Connectivity Issue
Hi,
I try to run a C# code on CentOS5 using mono version is 1.2.4. I compile my code by issuing command on terminal #gmcs Program.exe -r:System.Data the code compile successfully. when i run my code by issuing command on terminal #mono Program.exe ------------------------------------------------------------------------ OUTPUT is: Wowww //after pressing ENTER Unhandled Exception: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied at Syatem.Data.SqlClient.SqlConnection.Open () [0x0000] at Sqlprob.Program.Main(System.String[] args) [0x0000] ------------------------------------------------------------------------ My code is: using System; //using System.Collections.Generic; using System.Text; using System.Data.Sql; using System.Data.SqlClient; using System.Data; namespace sqlprob { class Program { static void Main(string[] args) { SqlConnection myConnection = new SqlConnection(@"Data Source=ITSECWIN3KSRV09\SQLEXPRESS; Initial Catalog=EMS_Enquirer_Logoinn_Phase2_Dev; User ID=sa; Pwd=admin;"); myConnection.Open(); try { if (myConnection.State.ToString() == "Open") { Console.WriteLine("Wowww"); Console.ReadLine(); } else { Console.WriteLine("Hooooowwww"); Console.ReadLine(); } }//end try catch(Exception ex) { Console.WriteLine(ex.Message + ex.Source); } SqlConnection mycon = new SqlConnection(@"Data Source=ITSECWIN3KSRV09\SQLEXPRESS; Initial Catalog=EMS_Enquirer_Logoinn_Phase2_Dev; User ID=sa; Pwd=admin;"); mycon.Open(); try { Console.WriteLine(mycon.State.ToString()); } catch(Exception ex) { Console.WriteLine(ex.Message+ex.Source); } } } } Please help me out. I am totally stuck in my application. Thanks in advance... |
This really sounds like a problem outside of your program. Have you checked to see if you can access the database outside of your program (e.g. using a client program)? If you're able to do that, the next place to look is the string you pass to make the connection.
Kevin Barry |
mono SQL Server Connectivity Issue
Thanks for your reply.
Yes First I run my code on Windows .Net framwork. It runs fine. But when I run my code on CentOS using mono its 1st time connect with server but at very next it throws exception as I indicates in my output. |
But can you connect on CentOS in the first place (e.g. with a standard client application)? You need to make sure it's even possible the way you have your system set up before you start trying to figure out why it doesn't work for your program.
Kevin Barry |
Yes I can connect my application with sql server in the envoirnment of CentOS. I don't think so that their is problem in connection string.
output which I show in my post is actually a runtime of CentOS. |
I don't know about mono, but postgresql has a default location to look for a socket for local connections. It could be that you have to configure that (or something similar) within the library you use to connect to it.
Kevin Barry |
Kevin I have resolved this problem by updating mono installation upto 2.4.2.3 version. Its now working fine.
Thanks for your support Cheers |
All times are GMT -5. The time now is 02:16 AM. |