textboxes in Datarepeater dynamically 'databound' - mysql

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.

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

Create a shared datasource in VS2012 for SSRS

I'm just looking to create a shared datasource in VS2012 without selecting an entire database scheme. We'll mostly put doing all the dataset queries by sql query.
I found this but i'm still unable to create a shared datasource.
http://msdn.microsoft.com/en-us/library/ms159165.aspx
For an embedded data source, verify that Embedded connection is selected. Does not exists.
So how do you create a shared datasource in VS2012 with just a connection string?
A DataSource is just a connection string in an element in an xml structure as far as SSRS is concerned. A shared one is just one kept as it's own object and then the rdl elements(reports) have a reference in their xml to that object. Think of an rds file (data source for SSRS) as this very similar to .NET standard connection strings:
Data Source=(server);Initial Catalog=(database)
Plus you can store credentials to mock who is running the report. Thus you can make a proxy user to run the database connection. However SSRS does this through a GUI called 'Business Intelligence Development Studio' it is an add on to Visual Studio that is generally SQL Server version matches that VS version EXCEPT FOR 2012. That one creates a shell Visual Studio of VS 2010 just meant for BIDS.
To my knowledge you should be creating these directly in BIDS and not try to hack the RDS file directly unless you get the ReportService2010.asmx web service to mess with it's properties in .NET (which is a lot more work.).
To add one you just do this:
Go into BIDS with a report project
Expand a project
Right Click 'Shared Data Sources'> 'Add New'
Click 'Edit...' next to connection string
You get a menu very similar to ADO.NET standard connection string creator
Put in ServerName
Put in DatabaseName
8*** Optional put in default credentials.
Click OK
Generally SSRS has three parts to everything it does
Datasource = connection string (rds file when not embedded)
Dataset = select query or proc results or other data source return (rsd file when not embedded)
Report = resultant xml display of elements such as parameters, tables, matrices, etc. (RDL file when working on hosted report)
Generally reports can have everything embedded or else just reference everything they use. References are often easier for deployments sake as SSRS is designed to look if DataSources first exist and NOT OVERWRITE them by default. Thus if you reuse a datasource it is much easier in the long run as long as policy for it is set up correct.
If you want to just know the structure of an rds file they look like this:
<?xml version="1.0" encoding="utf-8"?>
<RptDataSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Test">
<ConnectionProperties>
<Extension>SQL</Extension>
<ConnectString>Data Source=TestServer;Initial Catalog=TestDatabase</ConnectString>
</ConnectionProperties>
<DataSourceID>45be0ac1-80a8-4d5c-906b-c13b03298e0a</DataSourceID>
</RptDataSource>

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

Report model data

I'm working on ssrs 2008 r2 and from it, I'm building a report model using a relational database as a source.
I have many databases and all of them have the sames structure (same tables and same table fields).
from the first look on report model,all entities are generated from the data source view. Consequently, it doesn't allow for one report model to be used with multiple database.
Is there anyway to use the same report model for multiple databases ?
Ps: my report model has so many entities, for each one, I have to edit it.so you can see that what I need is to automate the process.
I was keen to see answers for this question since I have this same requirements for product I've inherited. But since you've not had any other answers perhaps this will help if I describe the setup we have.
Initial Deployment
Locally we have one Visual Studio 2008 (BIDS) Report Model project which contains one data source, and a number of data source views and reporting models. Each time a new database goes online, we change the connection string of the data source and update the deployment configuration of the project to target a different report server folder following the format /Models/<databaseName>. The model is then deployed using BIDS. The frequency of this is low, only happening once every couple of months. If we had to setup for lots database all at the same time this would be a slow and painful process. As a side note we limit access to each deployed model by configuring the security of each reporting folder i.e. the <databaseName> folder.
Model Updates
Since our initial deployment is manual, updating the model in the same way would be very painful. So I wrote a tool which makes use of the web services provided by SSRS to refresh our deployed models. At a high level this how this works; after changes are made to the report model found in BIDS project (remember we only have one project and not one for each deployed model) the tool loops for each database and calls the SetModelDefinition web service method passing in our updated model file. We're not changing the data source so the updated models on the report server will continue to use its configured data source. Again this only works because the data source name isn't changed per database.
For reference here's example C# code of what the tool does to bulk upload the model
// prepare the model for upload
string pathToSmdlFile = "c:\ReportModel.smdl";
string pathToDataSourceViewFile = "c:\ReportModel.dsv";
string semanticModel = System.IO.File.ReadAllText(pathToSmdlFile);
string dataSourceView = System.IO.File.ReadAllText(pathToDataSourceViewFile);
// combine the semanticModel and dataSourceView, BIDS does when you use the `deploy` action
// because we're doing this in code we have to combine
byte[] model = Encoding.UTF8.GetBytes(semanticModel.Replace("</SemanticModel>", dataSourceView + "\n</SemanticModel>"));
// upload model using web service
using (var rs = new ReportingService2005WS.ReportingService2005())
{
rs.Url = "http://yourserver/ReportServer/ReportService2005.asmx";
rs.Credentials = new System.Net.NetworkCredential("admin", "password");
foreach (string databaseName in GetDatabaseNames())
{
string fullpath = string.Format("/Models/{0}/ReportModel", databaseName);
rs.SetModelDefinition(fullpath, model);
}
}
I'm not saying this is the perfect setup - I actually think I should be possible to upload the reporting model once and have something change the data source at the point that the report is used. Perhaps its possible to configure the use of different data sources depending on the SSRS login used. Failing that the report itself should somehow pass the details of the correct data source to use (or connection string). On the flip side this does mean that our users don't have to know the details of the connection to the database. We just give them SSRS logins and allow them to build with report builder; because of the security applied to each database folder they are restricted to there database...

LINQ to SQL Connection String

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.