none
Error connecting to SQL Azure from ASP.NEt application via ole db

    Question

  • I'm currently putting together a demo for our company about SQL Azure.
    I created a very simple web application (todolist application) which should run on my computer and the database on SQL Azure.

    I succeeded in creating the table, putting data in it. I gave the following connection string to the application:
    Provider=SQLNCLI10;Server=tcp:flc7nyk2kr.ctp.database.windows.net;Database=test;Uid=UID;Pwd=PA$$WORD

    the following exception occurs:
    [OleDbException (0x80004005): Server name cannot be determined. It must appear as the first segment of the server's dns name (servername.ctp.database.windows.net). Some libraries do not send the server name, in which case the server name must be included as part of the user name (username@servername). In addition, if both formats are used, the server names must match.] System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +968809 System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +29 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4865468 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117 System.Data.OleDb.OleDbConnection.Open() +40 System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +31 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +112 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +94 ToDo.ToDoListForm.Page_Load(Object sender, EventArgs e) in s:\Dokumentumok\Visual Studio 2008\WebSites\ToDoApp\ToDoList.aspx.cs:116 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

    What could be the problem?

    Should I use an other library instead of OleDB?
    Tuesday, September 22, 2009 9:43 AM

Answers

  • I'll answer myself: if I replace the UID with UID@servername (flc7nyk2kr in my case) it works like a dream.

    I hope it helps to someone like me :)
    Tuesday, September 22, 2009 9:46 AM