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
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=adminsa;");
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=adminsa;");
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...
|