How can I change connection string value residing in external config file (vb 2010) - configuration-files

Going through MSDN and various other posts on line, I understand that we can very well do away with the older method of ini files for writing and retrieving configuration details so as to be able to change database path/connection string. (refer)
I am able to get the connection string data from an external file ("abcConnStr.config") and am able to read and write from / to the database tables as normally one would expect to.
However I am unable to crack the way I would be able to change / update the connection string value in the external file ("abcConnStr.config"). If I try to pass the value manually through a text box I get a message saying "Your step-into request resulted in an automatic step-over of a property or operator.....". When I click "Yes" the sub is completed without any further message or error. However when I open the config file ("abcConnStr.config"), I find that the value of the connection string has not changed.
May I request you to guide me as to how can I change the connection string parameter in the external config file ("abcConnStr.config").
Addl.info:
Here is the external config file that I am using:
File name: connStr.config
<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
<add name="NewConStr"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&
quot;D:\CATALOG\CATALOG_DB\CAT_DB.accdb""
providerName="System.Data.OleDb" />
</connectionStrings>
I am using the following code line in appication.exe.config (app.config) file to access the database:
<connectionStrings configSource="connStr.config" />
I am able to connect to the database if it resides in the file location as defined in the external config file. However, when I change the database location (put in another folder or change the name) as expected, the connection to the DB fails. At this point I am catching the exception and trying to call the sub to effect a change to the path value assigned to the "connectionString".
In the sub I want to call code/s to change the DB file path as selected by the user thru'"OpenFileDialog".
Kindly advise a possible way to achieve this.

I got the solution on here.
However, I will have to do away with external config file (for now, till I get a solution on it) and have ended up making changes to the application.exe.config file. It is working seamlessly.
I am using VB 2010 Pro.
Thanks.

Related

MSTest - Run "LoadTests" and Write Results to SQL Server Database

If you want to configure your VS "Load Tests" to write the results to a database server, you use the following instructions.
If you want to run your "Load Tests" through powershell on a separate machine(think TFS 2018 release step), you use the following instructions.
I would like to do both, on multiple machines, in a automated manner, but there's not a great deal of documentation on this, I can run my tests like this:
.\mstest /testcontainer:"C:\XXX\ABC.loadtest"
But the results are kicked out to a "TRX" file rather than being placed into a database(there is some discussion on this). How do I put the results into a external database like when I run it locally(per instructions above)?
Note: #AdrianHHH points out that the "TRX" file is only a summary and that most of the info is stored locally(MDF/LDF file) in the user folder of current user running the load tests.
Update 1
Hmm I wonder where this is persisted:
(Curious, also click on the "?" icon in the "Manage Test Controller" box, nothing...)
It's not in the saved XML:
<RunConfigurations>
<RunConfiguration Name="Run Settings1" Description="" ResultsStoreType="Database" TimingDetailsStorage="AllIndividualDetails" SaveTestLogsOnError="true" SaveTestLogsFrequency="0" MaxErrorDetails="200" MaxErrorsPerType="1000" MaxThresholdViolations="1000" MaxRequestUrlsReported="1000" UseTestIterations="false" RunDuration="10" WarmupTime="0" CoolDownTime="0" TestIterations="100" WebTestConnectionModel="ConnectionPerUser" WebTestConnectionPoolSize="50" SampleRate="5" ValidationLevel="High" SqlTracingConnectString="" SqlTracingConnectStringDisplayValue="" SqlTracingDirectory="" SqlTracingEnabled="false" SqlTracingFileCount="2" SqlTracingRolloverEnabled="true" SqlTracingMinimumDuration="500" RunUnitTestsInAppDomain="true" CoreCount="0" ResourcesRetentionTimeInMinutes="0" AgentDiagnosticsLevel="Warning">
<CounterSetMappings>
<CounterSetMapping ComputerName="[CONTROLLER MACHINE]">
<CounterSetReferences>
<CounterSetReference CounterSetName="LoadTest" />
<CounterSetReference CounterSetName="Controller" />
</CounterSetReferences>
</CounterSetMapping>
<CounterSetMapping ComputerName="[AGENT MACHINES]">
<CounterSetReferences>
<CounterSetReference CounterSetName="Agent" />
</CounterSetReferences>
</CounterSetMapping>
</CounterSetMappings>
<LoadGeneratorLocations>
<GeoLocation Location="Default" Percentage="100" />
</LoadGeneratorLocations>
</RunConfiguration>
</RunConfigurations>
They're not persisted in my default "testsettings" file either:
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Local" id="02cad612-043b-447d-993e-a9b9b0547c9d"
xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a local test run.</Description>
<Deployment enabled="false" />
<Execution hostProcessPlatform="MSIL">
<TestTypeSpecific />
<AgentRule name="Execution Agents">
</AgentRule>
</Execution>
<Properties>
<Property name="TestSettingsUIType" value="UnitTest" />
</Properties>
</TestSettings>
So I need to find where ever this configuration information is being persisted, then maybe I can find a way to feed it to MSTest. Does anyone else understand how this works?
Update 2
My TRX file does contains a "connection string" but I don't think it's to my database, my database is empty, on running via powershell it completes, but all I see is the "TRX" file.
Update 3
This one is tricky, I keep trying various ways to determine where this "Manage Test Configuration" data/credentials is being stored. One of the ways I did this was to use Microsoft's Process Monitor. You can actually see where it initially is being populated from:
It's from a Application Hive, of course that's begs the question where did the "Application Hive" get populated from, that's where things get a bit murky, there's allot of different calls to many files. A common trend is that the "Temp\Local" folder is often referenced.
I deleted the entire "Temp" folder for my user account(in the process losing all my VS configuration) and upon reopening my solution it appears as though this had an effect. When I pull up my "LoadTest" file, the "Load test results store" line is now empty. In fact the entire "Manage Test Controller" window has been restored back to default(empty).
I know believe that the configuration for this "Manage Test Controller" window is persisted in the temp folder. However, I've yet to locate where it is and/or how to change/automatically populate that information with a powershell script.
Finally figured this out. Basically I used several tools to check what files were being modified when I changed the connection string, the results made it obvious:
privateregistry.bin
Once I found this it was pretty obvious that VS was maintaining it's own little registry hive. It's clearly stated in this post, so I opened it in the way described in the article and found the connection string:
This indicated that:
"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."
So that's basically what I did, I logged into each build server and configured them so that they write all there results to my database rather than locally.
Load tests are clearly not designed to make this process easy, I don't think many people have attempted to do what I've done. All the articles just tell you to use their cloud service. I'm pretty sure that only covers web tests. If your using load testing to test unit tests you pretty much out of luck(without this work around). I really hope this gets official support in the future, it would be really nice to both run/view all types of load tests from TFS. For now though I'm going to have to keep using this work around.

how to copy local directory with files to remote server talend

in Talend(data integration) i am trying to copy local directory to remote directory but when i am running the job only i can copy files but not folders from directory.please help me with this job.
In my talend job i am using local connection and remote connection components->
tfilelist->tfileproperties(to store path and name in one table)->tmssqlinput(extracting path from last table)->iteration-> tssh(if directory s not available then create)->finally sending it to tftpput to connect and copy to remote directory.
when i am storing in one table using tfileproperties in that for files it will generate some size but when folder s coming the size will be zero,using this condition m creating the directory using tssh component but unable to create folders,please help me.
Do you get an error message?
I believe the output of the TMSSqlInput should be a row based, rather than iteration. That might be the source of the problem.
tMSqlInput docs
tMSSqlInput executes a DB query with a strictly defined order which
must correspond to the schema definition. Then it passes on the field
list to the next component via a Main row link.

Azure deployment connection string

New to Azure and have difficulty to connect DB with webapp. I am playing with a demo project using entityframework and code first mitigation. It works as expected in my local computer and localdb. But it does not work when I try to deploy it to Azure. I use the Webapp and a SQLDatabase in Azure. Then, I try to connect them using connection string in Webconfig.
<add name="DefaultConnection" connectionString="Server=tcp:dritor.database.windows.net,1433;Database=dritorDB;User ID=****#dritor;Password={****};Encrypt=True;TrustServerCertificate=False;Connection Timeout=30" providerName="System.Data.SqlClient" />
The homepage shows up as expected. But when I try to fetch data from DB (I put some data with seed), it returns something as follows:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Message>An error has occurred.</Message>
</Error>
I suspect that I made the connectionstring wrong but I am not sure. Any suggestions on how to debug in this situation would be appreciated.
The string looks correct except for the curly braces around the password. It should just be Password=****

How to show database in app_data when developing for azure with entity framework code first?

I am using the code first method in my windows azure project. I would like to see wich tables are created by the framework but the mdf file is not listed in the app_data folder.
I tried editing the default connection string to:
<add name="ModelContext" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ModelContext.mdf;User Instance=true;Database=ModelContext"
providerName="System.Data.SqlClient" />
When using this connection string I get the following error:
CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\Users\Myname\WindowsAzureProject1\MvcWebRole1\App_Data\ModelContext.mdf'.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
How can I solve this?
Any help is greatly appreciated.
This isn't the best way to do things. It is probably a permission problem. Take a look at this:
http://www.windowsazure.com/en-us/develop/net/tutorials/web-app-with-sql-azure/
It uses code first and works with Azure and starts out using SQL Express.
Sql Express is not installed in a web role. You need to use a Sql Azure database or add a start up task for the web role to install sql express. Take a look at this post from Steve Marx http://blog.smarx.com/posts/introduction-to-windows-azure-startup-tasks on how to add a start up task

GWT: Reading a file from the server at server's startup

I am trying to have the server read from a file, called "config.txt", in the same directory as the main .html file within the war.
In hosted mode, I can easily access the file using a Scanner object:
Scanner s = new Scanner("config.txt");
But this does not work when deployed because the file paths are somehow different. How can I get the correct file path to access config.txt in the deployed version?
I have tried getServletContext.getRealPath("config.txt"), but for some reason I get a Null Pointer Exception when I attempt to call this in the ServiceImpl's constructor...
It seems like getServletContext.getRealPath("/") is the way to go, but you just can't call the method within the constructor of the server implementation.
The way I eventually got around it was by calling it when the client first made its connection.