ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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;");
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.