[Mono-devel-list] ASP.NET and SQL SERVER 2000

Daniel Morgan danielmorgan at verizon.net
Wed Sep 22 17:20:09 EDT 2004


Are you using a instance name for the server name, such as,
Server=MYHOST\MYINSTANCE

You appear to be using SQL Server authentication instead of NT
Authentication.

It sounds like a timing issue.  The SqlClient provider maybe timing out.

-----Original Message-----
From: mono-devel-list-admin at lists.ximian.com
[mailto:mono-devel-list-admin at lists.ximian.com] On Behalf Of falconn at free.fr
Sent: Tuesday, September 21, 2004 7:35 AM
To: mono-devel-list at lists.ximian.com
Subject: [Mono-devel-list] ASP.NET and SQL SERVER 2000


Hi !

I've a strange problem with mono. I want to get informations from a database
under SQL SERVER. I tried the following example taken from the MonoHandbook
doing some modifications. But when I run it, sometimes it's working,
sometimes not : it shows an error message (something like it can't find the
sql server or I don't have access to the database). I tried to use unixODBC
with freetds and it works, but it's a little bit slow! So it doesn't seem to
be a problem with my SQL Server. Is it a bug?



Here is the code I use :

using System;
using System.Data;
using System.Data.SqlClient;

 public class Test
 {
    public static void Main(string[] args)
    {
  string connectionString =
     "Server=MyServer;" +
     "Database=pubs;" +
     "User ID=MySqlServerUserId;" +
     "Password=MySqlServerPassword;";
  IDbConnection dbcon;
  dbcon = new SqlConnection(connectionString);
  dbcon.Open();
  IDbCommand dbcmd = dbcon.CreateCommand();
  string sql =
      "SELECT fname, lname " +
      "FROM employee";
  dbcmd.CommandText = sql;
  IDataReader reader = dbcmd.ExecuteReader();
  while(reader.Read()) {
  string FirstName = (string) reader["fname"];
  string LastName = (string) reader["lname"];
  Console.WriteLine("Name: " +
       FirstName + " " + LastName);
  }
  // clean up
  reader.Close();
  reader = null;
  dbcmd.Dispose();
  dbcmd = null;
  dbcon.Close();
  dbcon = null;
    }
 }


Here is the error message when it doesn't work :

mono testing.exe

Unhandled Exception: System.Data.SqlClient.SqlException: SQL Server does not
exist or access denied. in <0x0020e>
System.Data.SqlClient.SqlConnection:Open () in <0x00066> Test:Main
(string[])

zsh: exit 1     mono testing.exe

I have tested the connexion with SQLSharp and the problem remains the
same... _______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list