Can not configure Data Access v 2.0 !!!

Topics: Data Access Application Block
Jun 12, 2008 at 9:11 PM
Edited Jun 12, 2008 at 9:11 PM
I am not sure if this is a forum for questions, but I am going crazy trying to figure out why the Enterprise Configuration Tool for the Connection String continues to always have a default connection to the ASP default SQL Server instance, even when I delete it and try to create a new link, it is always there.  I am using a Windows Form project with the app.config in the root directory, not the bin/debug directory... any advice?
Craig
Jun 12, 2008 at 9:32 PM
This post from Tom should help you http://blogs.msdn.com/tomholl/archive/2006/04/25/583796.aspx. Now, what do you mean by "try to create a new link"?

Fernando


cjsteury wrote:
I am not sure if this is a forum for questions, but I am going crazy trying to figure out why the Enterprise Configuration Tool for the Connection String continues to always have a default connection to the ASP default SQL Server instance, even when I delete it and try to create a new link, it is always there.  I am using a Windows Form project with the app.config in the root directory, not the bin/debug directory... any advice?
Craig



Jun 12, 2008 at 11:19 PM

Hey Fernando,
I thought that duplicate connection string from machine.config was causing my connection string not to work.  So, I thought there should only be one connection string, but that apparently is not the case.  That is what I meant by 'try to create a link'... however, if you have the patience or where with all to offer me some advice... here is my test scenario...

1.  I have configured a connection entitled 'myConnectionString' to have the same structure as the default ASP 'localSqlServer' also as is defined in the Microsoft documentation (ie... database, server, integrated security) and I've tried to structure it to match the Visual Studio ASP.net config... (data source, initial catalog, integrated security).

ie   myConnectionString=Database=Stocks;Server=Dell6000;Integrated Security=SSPI
ie...myConnectionString=Data Source=DELL6000;Initial Catalog=STOCKS;Integrated Security=True

In either case the command

Database db = DatabaseFactory.CreateDatabase("Stocks")   // DOES NOT WORK ... ('no Stocks db defined')  However the following
Database db = DatabaseFactory.CreateDatabase("myConnectionString")   // DOES WORK.... (or at least does not error)

The stored procedure does not execute however!!  I have tested the stored procedure manually against the database and it works great... What could I be doing wrong.

here is my procedure execution method:

        public void testDB()
        {
            Database db = DatabaseFactory.CreateDatabase("myConnectionString");
            string sqlCommand = "dbo.UpdteMstr2";
            DbCommand dbCmd = db.GetStoredProcCommand(sqlCommand);
        }

and this is the button click event...

        private void button4_Click(object sender, EventArgs e)
        {
            YahooStocks.TestDB Tst = new TestDB();
            Tst.testDB();
            SetControlProperty(label4, "Text", "DONE!!!");
            label4.Refresh();
        }
it executes the "DONE!!!"  but the the database is not updated via the stored procedure.. (which works fine against the db manually as stated)...
I am at a loss....(!
Craig










fsimonazzi wrote:
This post from Tom should help you http://blogs.msdn.com/tomholl/archive/2006/04/25/583796.aspx. Now, what do you mean by "try to create a new link"?

Fernando


cjsteury wrote:
I am not sure if this is a forum for questions, but I am going crazy trying to figure out why the Enterprise Configuration Tool for the Connection String continues to always have a default connection to the ASP default SQL Server instance, even when I delete it and try to create a new link, it is always there.  I am using a Windows Form project with the app.config in the root directory, not the bin/debug directory... any advice?
Craig






Jun 13, 2008 at 1:57 AM
It appears you are missing, db.ExecuteNonQuery(dbCmd) in there....

here is my procedure execution method:

        public void testDB()
        {
            Database db = DatabaseFactory.CreateDatabase("myConnectionString");
            string sqlCommand = "dbo.UpdteMstr2";
            DbCommand dbCmd = db.GetStoredProcCommand(sqlCommand);
        }

and this is the button click event...

        private void button4_Click(object sender, EventArgs e)
        {
            YahooStocks.TestDB Tst = new TestDB();
            Tst.testDB();
            SetControlProperty(label4, "Text", "DONE!!!");
            label4.Refresh();
        }
it executes the "DONE!!!"  but the the database is not updated via the stored procedure.. (which works fine against the db manually as stated)...
I am at a loss....(!
Craig










fsimonazzi wrote:
This post from Tom should help you http://blogs.msdn.com/tomholl/archive/2006/04/25/583796.aspx. Now, what do you mean by "try to create a new link"?

Fernando


cjsteury wrote:
I am not sure if this is a forum for questions, but I am going crazy trying to figure out why the Enterprise Configuration Tool for the Connection String continues to always have a default connection to the ASP default SQL Server instance, even when I delete it and try to create a new link, it is always there.  I am using a Windows Form project with the app.config in the root directory, not the bin/debug directory... any advice?
Craig









Jun 13, 2008 at 5:51 PM
What the heck!
Okay, I am either a complete idiot or the Microsoft documentation is a little vague on this aspect of the coding in the example scenarios, as I inserted this line and it works great!
Oh well.
wtf!
Thanks,
CS



pbolduc wrote:
It appears you are missing, db.ExecuteNonQuery(dbCmd) in there....

here is my procedure execution method:

        public void testDB()
        {
            Database db = DatabaseFactory.CreateDatabase("myConnectionString");
            string sqlCommand = "dbo.UpdteMstr2";
            DbCommand dbCmd = db.GetStoredProcCommand(sqlCommand);
        }

and this is the button click event...

        private void button4_Click(object sender, EventArgs e)
        {
            YahooStocks.TestDB Tst = new TestDB();
            Tst.testDB();
            SetControlProperty(label4, "Text", "DONE!!!");
            label4.Refresh();
        }
it executes the "DONE!!!"  but the the database is not updated via the stored procedure.. (which works fine against the db manually as stated)...
I am at a loss....(!
Craig










fsimonazzi wrote:
This post from Tom should help you http://blogs.msdn.com/tomholl/archive/2006/04/25/583796.aspx. Now, what do you mean by "try to create a new link"?

Fernando


cjsteury wrote:
I am not sure if this is a forum for questions, but I am going crazy trying to figure out why the Enterprise Configuration Tool for the Connection String continues to always have a default connection to the ASP default SQL Server instance, even when I delete it and try to create a new link, it is always there.  I am using a Windows Form project with the app.config in the root directory, not the bin/debug directory... any advice?
Craig