LINQ to SQL Connection String - linq-to-sql

I've used LINQ to SQL in a unit testing project to mock some test data. I've changed the database name today and consequently the LINQ to SQL code doesn't work any more. I get the following error 'System.Data.SqlClient.SqlException: Cannot open database "XXX" requested by the login. The login failed'. I've tried changing the Connection property on the DataContext in the designer but this doesn't work. I've tried changing the connection string in app.config as well but this doesn't work as well. Is there anything I missing here?

I managed to solve this problem: In opened up the .dbml file in the XML editor (rather than the designer) and found a Database element with the old database name referenced. Once I changed this then everything was OK.

Related

MySQL ODBC configuration

I have managed to make my Access work as a frontend for MySQL.
I have managed to make it work through connection string but because some specifics in code i would like to save DSN configuration as user DSN.
I have ran into one specific problem. I need to use option=3 inside my connection string because without option=3 i get error: The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.
If i include option=3 in my connection string everything works well. The thing is, in Mysql Connector/ODBC data source configuration i do not know which checkbox/option represents option=3
The doc about this is here : Connector/ODBC Connection Parameters
option=3 looks deprecated as specified in this answer :
Option=3; corresponded to FLAG_FIELD_LENGTH (1) +
FLAG_FOUND_ROWS (2)
It looks indeed deprecated as in the doc I can't find any reference to FLAG_FIELD_LENGTH
We can thus assume that the flag you really need is FLAG_FOUND_ROWS
According to the doc, the GUI option for this flag is
Return matched rows instead of affected rows

Unusual Message Source Name in SSIS standard Report

Usually, in a dtsx Standard Report, there is a column "Message Source Name" that indicates which dtsx threw the error or raised the event.
Now i get "Transact-SQL stored procedure" and of course I don't have such a dtsx.
So, question #1 is: Where should I go to check the error?
Besides, the error is: An error occurred while setting the value of a property "InitialCatalog". The error returned is 0x80020009. The connection string components cannot contain unquoted semicolons....
My dtsx were doing fine and I was publishing dtsx on a regular basis with no problems. Then, I changed the name of a ConnectionManager and took care of changing this name wherever it appeared.
After this fateful move, I cannot manage to restore the previous situation. Even rollbacking all changes through TFS and going back to the previous names doesn't solve the matter.
I checked also the environment I am using and the configuration of the job that launches the dtsx, to no avail.
If I execute the dtsx on my development machine, from visual studio, it works fine. The problem arises in production enviroment when I use the job configured with the environment. In the project configuration and in the environment configuration I don't see what an "unquoted semicolumn" could be.
The value of the connection string that is indicated as having an error looks like:
Data Source=11.1.1.11,1111;Initial Catalog=MyDB;Provider=SQLNCLI11.1; Integrated Security=SSPI ;Auto Translate=False;
Question #2 is: Where could this connection string with unquoted semicolon be?
Thx.
With much effort I managed to find an answer to Question #2:
I am using parametrized connection managers, so I have a project parameter (let's call it PP1) in my dtsx with the connString.
During configuration of the SSIS project I need to give a value ONLY for the parameter PP1, and NOT for the connection string.
What I did wrong was to give the Environment Variable with the connString to the Property "Initial Catalog". Therefore, SSIS was lamenting of the presence of ";" (the ones in the connString) in the InitialCatalog.

ssis oledb source, as400 parameter not found

I'm using ssis 2008 and I'm trying to get data from an as400 database.
I have a Data Flow Task, and inside it, I have an Oledb Source and in there, I have Data access mode to Sql Command, and I have a query:
select *
from table1
where name = ?
Then i click on the Parameters button and set "name1" for the name of my parameter.
When i ran the ssis, i got error:
Error: The SQL command requires a parameter named ""00001"", which is
not found in the parameter mapping.
So I changed the parameter name to ""00001"" and the ssis worked fine.
Now, the problem is that this same ssis needed to be ran on another as400 server, and older one, and when it ran it showed error:
Error: The SQL command requires a parameter named "", which is
not found in the parameter mapping.
So, now the other server requires a different parameter name.
Is there another way of doing this process using something different than Oledb Source in order to avoid the problem?
What can I do?
We are using sql 2012 and a as400 system and we use a ODBC source for the as400. For our setup it seems to be working. So try the ODBC.
Well, this seems to be an as400 bug, as seen here : [link]http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/5d6ef4f9-1a67-45d1-8a49-eb08becf1408/
On that thread a user says: "This bug is directly related to IBMDA400 from IBM Client Access Tools. There is a bug with the driver passing a parameter to the AS/400. I have proved this out using a third party driver from HiT Software. Passing 00001 is correct using their drivers."
So as I see, it wont matter the method you use, what's need to be done in order to get it working is to pass the parameter with name that AS400 requires. If the parameter with the correct name is passed then the query will work correctly.

Local Load Testing: The load test results database could not be opened

I am creating some Load tests using VS2012. I can run the tests using a StorageType of "None", but when I change this to a StorageType of "Database" I get the dreaded error
The load test results database could not be opened. Check that the
load test results database specified by the connect string for your
test controller (or local machine) specifies a database that contains
the load test schema and that is currently available. For more
information, see the Visual Studio help topic 'About the Load Test
Results Store'. The connection error was: An error occurred while
attempting to create the load test results repository schema: To
create the database 'LoadTest2010' your user account must have the
either the SQL Server 'sysadmin' role or both the 'serveradmin' and
'dbcreator' roles
I have created a database on a non local copy of SQL called LoadTest. When I test the connection from the SQL Tracing Connect String dialog I get a success.
I have created a SQL user that has the Server Roles of dbcreator, public, serveradmin and sysadmin. The user has a User Mapping to the LoadTest2010 database that was created from the loadtestresultsrepository.sql in the VS2012 IDE directory. On the database the user has the Database role memberships db_accessadmin, db_datareader, db_datawriter, db_owner.
In the Owned Schemas i ticked on the db_datareader, db_datawriter, db_owner and db_securityadmin howver these have now gone to a blue square instead of a tick when displayed.
So what's going on? Is Visual studio trying to create the database or is something else the issue?
I am not using TestControllers or TestAgents I am simply using a local run.
The answer was simple. I was setting up the connection string in the "SQL Tracing Connect String" instead of clicking the little "Manage Test Controller" icon at the top of my load test window and setting up the connection string from there.
Now I'm off to remove some of those superfluous permissions I created on that SQL user :)
Edit:
The SQL Connection String is NOT stored in the loadtest files. The setting seems to be PC specific so I had to change it on the build server - in one loadtest file (address.loadtest) as shown, then all the other loadtests adopt the same connection string.
I am using Visual Studio 2013 and had this error as well, but for a different reason. It's not entirely clear when setting up a load test for the first time that it will attempt to save the results to a database by default. I didn't realize it was trying to save results to a database until I got the error on my first run attempt. Furthermore, in the load test wizard, there is no screen to configure the database settings or create the database schema for that matter.
I found this article on MSDN which helped me solve the problem.
How to: Create a Load Test Results Repository Using SQL
https://msdn.microsoft.com/en-us/library/ms182600%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396
Basically, it explains that you first need to run a script to create the load test repository schema. Once this is in place on your SQL instance is (it could be anywhere you like), then you can point your load test to this database and save your results there.
For me after I had set database connections and all the test results was still not writing to the database.
I forgot to change my storage type in the properties section of the runsettings.
The property is called 'Storage Type'
Storage Type : change it from None to Database

textboxes in Datarepeater dynamically 'databound'

I need to know if it is possible to dynamically bind a textbox residing within a datarepeater to a 'dynamically' created BindingSource. I am using VB.net. The database I am using is a MySQL database.
I have to use the connection dynamically due to the fact that the database my not permanently reside on the same server.
[edit]
ok, so it seams that I am a dolt when asking questions. The app that I am making is not web based. it is a simple (I hope) app that connects to a MySQL database, accesses a table so I can edit/view it. Current setup is using the Add DataSource wizard. I have successfully connected to the dbase dynamically using the mysql connector dll but without the textboxes set at design time to a datasource, I am unsure on how to 'link' them via the datarepeater.
Your connection string should be defined in your Web.Config, and if you move your database to a different server, it's just a matter of modifying the web.config entry. As long as you keep the connection string name the same, the BindingSource object will pick up the new value from the config.edit
In truth, the same concept should apply here as it does in the web app answer listed above.
All of your data objects should be hard-coded, and it's just the connection string (which you'll have to either ask the user for, or push out as update when the DB moves) which will get modified.
For example, create a App.Config file in your project. Have one of your configuration values be the connection string. This config value will be where you go to get the connection string whenever you need it. Then your wizard will be there to allow users to easily modify the connection.
then look in app.config
the conenction string should be there.
If it is not then you should put it in here as you can change this file at any time and not have to recompile your app.