LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-13-2009, 06:07 AM   #1
aeman
LQ Newbie
 
Registered: Sep 2008
Posts: 5

Rep: Reputation: 0
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...
 
Old 10-13-2009, 07:26 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
Old 10-13-2009, 07:55 AM   #3
aeman
LQ Newbie
 
Registered: Sep 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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.
 
Old 10-13-2009, 10:30 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
Old 10-14-2009, 01:25 AM   #5
aeman
LQ Newbie
 
Registered: Sep 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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.
 
Old 10-14-2009, 04:44 PM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
Old 10-15-2009, 12:23 AM   #7
aeman
LQ Newbie
 
Registered: Sep 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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
 
  


Reply

Tags
mono, server, sql


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mono SQL Server Connectivity Issue aeman Linux - Newbie 0 10-12-2009 04:59 AM
Connectivity Issue rajaniyer123 Solaris / OpenSolaris 4 07-04-2007 10:29 AM
Mono issue with compilation drewbug01 Linux - Software 4 03-02-2007 05:04 PM
Migrating from MS-SQL server to My-SQL emailssent Linux - Networking 2 02-07-2005 02:20 PM
Mono sound issue with KDE stabile007 Slackware 5 07-28-2004 08:39 AM


All times are GMT -5. The time now is 05:52 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration