none
problem when moving vs2005 database solution (SQL server) RRS feed

  • Question

  • Hi everybody !

    1. I'm working on a project with vs2005 , SQL server express 2005 , ADO.net datasets in C# .

    2. The project includes 4 datasets .

    3. The same project files exists on two PC's , one for development and one working on customer site .

    4. A problem  appears when I copy all the files from Customer computer to my computer , I can't access the SQL server/ Data (I get an error).

    5.  the computers names and SQL servers names are the same on both computers also the database !!!.

    6. I'm using Windows Authentication to connect on both !.

    7. The SQL servers are local (both).

    8. The connection string (in the APP.CONFIG file) is the same !

    So I can't find anything wrong ?!!!!....

    PLEASE HELP !

    Thanks ! 


    Sunday, March 25, 2012 7:24 AM

Answers

  • Sorry guys !!!.........

    I think I need a pair of new glasses :-) .

    look carefully on the connections string I quote ON : Wednesday, March 28, 2012 6:04 AM :

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="TTSManager.Properties.Settings.DelekMConnectionString"
                connectionString="Data Source=PORJ\SQLEXPRESS;Initial Catalog=DelekM;Integrated Security=True"            providerName="System.Data.SqlClient" />

            <add name="TTSManager.Properties.Settings.DelekMConnectionString1"
                connectionString="Data Source=PROJ\SQLEXPRESS;Initial Catalog=DelekM;Integrated Security=True"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    </configuration>

    My  apologies again !!! (especially to BonnieB

    everything works fine now !!!

    Thanks to all !!

    • Marked as answer by nuni1 Tuesday, April 3, 2012 7:04 AM
    Tuesday, April 3, 2012 7:04 AM

All replies

  • Might be nice if you tell us what the error is ...

    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Sunday, March 25, 2012 4:39 PM
  • Sorry !!

    When trying to do to a Preview of a existing Datatable in the .xsd Dataset designer ! 


    • Edited by nuni1 Sunday, March 25, 2012 5:26 PM
    Sunday, March 25, 2012 5:22 PM
  • Which files are you copying from the Customer? Are you sure the config files are the same?  Are you aware of the fact that the app.config in your project is copied to your bin\debug (or bin\release) folder and called MyApp.exe.config? Make sure that those are the same too (and pointing to the correct database).

    So, ok you can't preview the data in the DataSet Designer, but what happens when you try to run the app? Can it find the database then?

    You have the source code at your Customer's site? That's really not a good idea ... it's too easy for your source code to get out of sync.


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Sunday, March 25, 2012 7:41 PM
  • Hi nuni1,

    Welcome to MSDN Forum.

    Have you solved the issue? @Bonnie always can solve issues, she's a magician! If you have any problems, please feel free to post here.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, March 27, 2012 2:33 AM
    Moderator
  • Nuni,

    In my perception 100% technical (system admin), inspect if the database server and database is really on the path stated in the connectionstring.

    However, be aware a DataBaseServer Name is a DNS name so you cannot have twice with the same name on one computer.


    Success
    Cor

    Tuesday, March 27, 2012 7:49 AM
  • @Bonnie always can solve issues, she's a magician!

    LOL! Thanks Allen ... I sure wish that was true!  ;0)


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Tuesday, March 27, 2012 2:22 PM
  • Hi guys !!

    First thanks for suggestions !

    second I checked all the above . the configuration files are all OK !!! it is obvious that something with the connection to the sql server is wrong !!.

    What is strange is that when I add a new DataSet to the project/solution (which is working !!), the new connection configuration string (in app.config)

    is exactly the same BUT flowed by '1' like :   

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="TTSManager.Properties.Settings.DelekMConnectionString"
                connectionString="Data Source=PORJ\SQLEXPRESS;Initial Catalog=DelekM;Integrated Security=True"
                providerName="System.Data.SqlClient" />
            <add name="TTSManager.Properties.Settings.DelekMConnectionString1"
                connectionString="Data Source=PROJ\SQLEXPRESS;Initial Catalog=DelekM;Integrated Security=True"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    </configuration>

    ????..........

    • Edited by nuni1 Wednesday, March 28, 2012 6:08 AM
    Wednesday, March 28, 2012 6:04 AM
  • Yea then remove the connectionstring you don't need.

    :-)

    I know this, can be anoying

    :-)


    Success
    Cor

    Thursday, March 29, 2012 7:20 AM
  • So Nuni, I don't think you answered one of my earlier questions:

    ... you can't preview the data in the DataSet Designer, but what happens when you try to run the app? Can it find the database then?


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Thursday, March 29, 2012 3:06 PM
  • When running the app I get :

    ust-in-time (JIT) debugging instead of this dialog box.


    ************** Exception Text **************
    System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
       at TTSManager.DSManagerTableAdapters.CarTypeTableAdapter.Fill(CarTypeDataTable dataTable) in C:\Documents and Settings\nuni\Desktop\TTSManager\DSManager.Designer.cs:line 2343
       at TTSManager.TTsManager.TTsManager_Load(Object sender, EventArgs e) in C:\Documents and Settings\nuni\Desktop\TTSManager\TTsManager.cs:line 26
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)




    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3615 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    TTSManager
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/nuni/Desktop/TTSManager/bin/Debug/TTSManager.exe
    ----------------------------------------

    ETC. ........................

    Thanks !!!!!!

    Friday, March 30, 2012 9:14 AM
  • So, yeah, you still have a problem with which connection string to use. I just noticed this from your first post:

    7. The SQL servers are local (both).
    So I guess you are copying the customer's database too? I guess I missed that, although Cor did mention something about you can't have two databases with the same name on one computer. Can you fill in the details on this a bit more?

    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Friday, March 30, 2012 2:55 PM
  • Well :

    1. Basically the two databases were copied from the beginning (both LOCAL).

    2. Since then the customer database was changed (ONLY data was added !).

    3. There are no TWO databases with the same name , I think it's not possible !!!.....

    Thanks again !!

    P.S - do you think I need now to  copy the customers database to my computer again ?

     

    Sunday, April 1, 2012 6:28 AM
  • I'm  not real familar with SQL Server Express, as I only use SQL Server and I think that there are some differences. Do you have SQL Server Management Studio (I don't know if that comes with Express or not). If so, you should use it to take a look at your databases.

    You should probably read this for more information on managing Express:

    http://msdn.microsoft.com/en-us/library/ms165716.aspx

    I also found this thread:

    http://stackoverflow.com/questions/3612149/copy-sql-server-express-database-to-another-computer

    The relevant post from that StackOverflow thread follows:

    1. Make sure target db does not have that db attached, delete it first in SSMS.
    2. Move the .MDF by itself (without the log file).
    3. At target location default c:\program files...sql..\DATA make sure all prior instance of MDF and LDF are moved or deleted -- if it sees an .ldf there it gets confused.
    4. In SSMS, choose to attach. Press Add, select the .mdf.
    5. At this point, in the box right below, it will show that an MDF and LDF are attached and that the LDF is missing. Click the LDF and press the REMOVE button.
    6. Now the MDF will be attached and a new/empty LDF will be added.

    I do this all the time; works perfectly -- saves the trouble of transporting a large .ldf. (I often use dropbox.com instead of a thumb drive and encrypt the file with PKZIP/SecureZip first.)

    I'm not sure what happens if you copy the MDF with the server started, though I do not stop it before copying.

    If the above doesn't help, do a Google search on "SQL Server Express copying a database" ...


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Sunday, April 1, 2012 9:14 PM
  • Thank you BonnieB !

    I have the SQL Server Management Studio Express , I hope I can do the above !

    I'll try what you suggested and I'll inform the thread ! 

    Monday, April 2, 2012 6:15 AM
  • Sorry guys !!!.........

    I think I need a pair of new glasses :-) .

    look carefully on the connections string I quote ON : Wednesday, March 28, 2012 6:04 AM :

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="TTSManager.Properties.Settings.DelekMConnectionString"
                connectionString="Data Source=PORJ\SQLEXPRESS;Initial Catalog=DelekM;Integrated Security=True"            providerName="System.Data.SqlClient" />

            <add name="TTSManager.Properties.Settings.DelekMConnectionString1"
                connectionString="Data Source=PROJ\SQLEXPRESS;Initial Catalog=DelekM;Integrated Security=True"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    </configuration>

    My  apologies again !!! (especially to BonnieB

    everything works fine now !!!

    Thanks to all !!

    • Marked as answer by nuni1 Tuesday, April 3, 2012 7:04 AM
    Tuesday, April 3, 2012 7:04 AM
  • The important thing is that you found the problem! Well, that and also that you've discovered that you probably need new glasses. ;0)

    That's a very easy typo to miss ... we've all done that, I'm sure. Good luck with the rest of your project!


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Tuesday, April 3, 2012 4:56 PM