Changing Connection String (Dataset) before its Rendered on a Vb.Project - mysql

My purpose is I want to change the value of this Application Scope Connection String using Code.
So, I have this dataset database for my vb.net project. and it's fully working
(fully rendered) when we're running the app.
If you open the project setting, it is stored on Connection String.
It is using Applicatio Scope. Not user Scope. ANd it's
saved with its value ; "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ProgramData\RK-Medis\db-used.mdb"
My questions are:
Can we change that variable value of Connection String before its
called / rendered on its GUI?
WHat are the code for changing it?
If no we can't change it, then what are the alternative for using
dataset + its Connection String that automatically used in almost
many tables (GUI) i have...?

Perhaps you need a tableConnectionString for example, to store the CS for each user. Then use a property of string(or maybe const variable) to store your connection string for that particular user during user login. Substitude the CS to your application. Then each of the user will be able to have different CS.
Hope its give you the idea.

Related

Shared data set for cached reports?

Is there a way in SSRS to create a snapshot for a report that uses a shared dataset? We are looking for a way to dynamically set the server and credentials in SSRS, but it seems when the shared dataset is used there is no way to cache a report.
Two things that I think may help you:
You can create a dynamic connection string from parameters you pass in. However you lose intellisense when creating this so generally I use an actual database first to do my dataset then change the connection string later:
A. Create a variable #Server, set it to text:
B. Create a local DataSource, this must be local as you cannot share a data source that is dynamic, to my knowledge as it has no input to go on thus a shared must have set inputs.
C. On the side of 'Connection string:' hit the 'fx' button to get a dynamic connection string. Build a connection string of text with your parameter being an input:
="Data Source=" & Parameters!Server.Value & ";Initial Catalog=(DBName)"
D. You NOW have to set up a dataset to bind to #Server variable or else someone just needs to do plain text to guess at a server. For this reason I usually create a dataset like
select 'Server1' as Server
union
select 'Server2'
union
select 'Server3'
You can handle the cache aspect COMPLETELY from the hosted end and not worry about the report stuff. Just go to a report once deployed and choose 'Manage'>'Snapshot Options'> Set your preferences.
EDIT: You probably want another variable for the database or else you will assume a same database structure all the time.

How to define connection string for multiple environments in SSIS?

Anyone have any idea how do we specify different connection strings in SSIS for different environments - like system integration test environment, user acceptance test environment and production environment?
Is it done by defining multiple connection managers or we can define multiple configuration files and point our connection string to?
You do not need to have multiple connections for the same database.
In SSIS 2008:
It's a good idea to have your connection strings defined using an expression. This is how you can do it:
Suppose you have added a anew OLEDB connection in your connection manager. Copy the value of the ConnectionString property. IT would look like this:
Data Source=(local);Initial Catalog=Learn;Provider=SQLNCLI10.1;Integrated Security=SSPI;Application Name=SSIS-RaggedFile-{03053F2E-8101-4985-9F2B-8C2DDE510065}(local).Learn;Auto Translate=False;
Remove the non-essentials:
Data Source=(local);Initial Catalog=Learn;Provider=SQLNCLI10.1;Integrated Security=SSPI;
Now create three new variables at the control surface level: sServer, sDb, sProvider. Type for all these three varaibles will be string. Their values - using this example - will be (local), Learn, and SQLNCLI10.1.
Go back to the ConnectionString property of your connection. and set its value to
"Data Source=(local);Initial Catalog=Learn;Provider=SQLNCLI10.1;Integrated Security=SSPI;"
Now, replace the server, db, and provider with the variables you have created to make your expression look like this:
"Data Source=" + #[User::sServer] + ";Initial Catalog=" + #[User::sDb] + ";Provider=" + #[User::sProvider] + ";Integrated Security=SSPI;"
When we move from one environment to another, we may encounter different versions of the databases - hence it is helpful to have a variable for provider as well.
Now, these values can be changed at the time of deployment.
In SSIS 2012 -
This method would still work with a little bit of change. Change these three variables to parameters and make them required. That way, at the time of deployment of deployment, you will be forced to change the values. This is just a starting point. Read up on server environment.
Note: I opine that a variable should have atomic value. This helps in avoiding any error due to mistyping. That's why I have created three separate variables as opposed to having one variable called sCnxn (for example) and have someone change a portion of that variable at the time of deployment.

Saving form fields in a MySQL DB usinf Flex

I have a MySQL database, and i created a DB and named it 'PERSONDB'. Within that DB, i have created a table and named it Person. This table has 3 fields. id,name,age.
Now i need to save some values from my flex website to the mySQL 'PERSONDB' that i created.
How can i do this in Flex (Flax builder 4.6)
Note: I have added 2 fields name and age, in the Flex project and when the user clicks on the Button i need those values to be saved in the DB. how can i do this.
asSQL ( http://code.google.com/p/assql/ ) is a good approach to using mySQL. It allows for direct access to mySQL from any application either in AIR or web based. I use this pretty regularly in my coding so I don't have to write a Java or PHP as a back end unless there is a good reason to have a back end in place.
OK, here is the code I use:
<assql:MySqlService id ="DB"
hostname ="localhost"
username ="user"
password ="password"
database ="db"
autoConnect="true"
connect ="handleConnected(event)"
sqlError ="handleError(event)"/>
private function getSelectedData() : void
{
DB.send("SELECT * from table WHERE number = '" + number.text + "'");
}
That's all there is too it. The top part sets up the connection and is in the section of the code. The rest is in the part (ActionScript). Of course, it can be done in straight ActionScript as well, but this solution used MXML.

SSIS: Overwite the data source/server in a connection string read from a package configuration value

I have looked at other posts and questions but I couldn't find what I needed.
I am relatively new to SSIS Package creation so bear with me please.
Basically, I need the package to connect to multiple servers based on a list of IPs read from a table. I have a connection string that I am reading from a config table. the connection string is generic in that the datasource is simply 255.255.255.255 and I want to replace the datasource with the IPs read from the table as I loop through during package execution.
I am using IPs since the servers I am connecting to are not on our domain. I have set up the server name as a variable within the connection manager expressions. Thus what I am hoping is that the pkg config is read to obtain the entire connection string. Then as I loop through the IPs, the server name variable will be dynamically substituted into the data source value as it loops thorugh. I hope this makes sense.
So the connstring is: (generic within config table)
Data Source=255.255.255.255,65000;User ID=test;Password=test;Initial Catalog=myDB;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Application Name=SSIS-myApp;
Then as I obtain the list of IPs I want it to change to and then obviously connect as:
Data Source=1.1.1.1,1000;User ID=test;Password=test;Initial Catalog=myDB;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Application Name=SSIS-myApp;
Then the next IP and connect as:
Data Source=2.2.2.2,1000;User ID=test;Password=test;Initial Catalog=myDB;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Application Name=SSIS-myApp;
How can I do this using SSIS?
Create a connection manager connection to a valid database.
Right click on the newly created connection manager connection, select to Properties and copy the value for the connection string
Create a string variable and paste the connection string in your clip board in the value for the newly created variable
Add an Execute SQL Task with a statement similar to this:
SELECT TOP 1
'Data Source=' + [IPAddress] +
';User ID='+[Username] +
...
FROM dbo.IPTable
Pass the result set to the string variable you previously created
Right click on your connection manager connection and click the ellipsis next to Expressions
In the dialog that pops out, under Property, select ConnectionString and click the ellipsis next to the blank value for Expression.
In the Expression Builder, add the variable name to the variable you created. Ex: #[User::CreatedVariableName]
And you're finished. This a basic concept and you can tweak from there..

Classic ASP/MySQL - Parameter Issue

I have been trying to insert a huge text-editor string in to my database. The application I'm developing allows my client to create and edit their website terms and conditions from the admin part of their website. So as you can imagine, they are incredibly long. I have got to 18,000+ characters in length and I have now received an error when trying to add another load of text.
The error I am receiving is this:
ADODB.Command error '800a0d5d'
Application uses a value of the wrong type for the current operation
Which points to this part of my application, specifically the Set newParameter line:
Const adVarChar = 200
Const adParamInput = 1
Set newParameter = cmdConn.CreateParameter("#policyBody", adVarChar, adParamInput, Len(policyBody), policyBody)
cmdConn.Parameters.Append newParameter
Now this policy I am creating, that is currently 18,000+ characters in length, is only half complete, if that. It could jump to 50 - 60,000! I tried using adLongVarChar = 201 ADO type but this still didn't fix it.
Am I doing the right thing for such a large entry? If I am doing the right thing, how can I fix this issue? ...or if I'm doing the wrong thing, what is the right one?
Try to avoid putting documents in your database if you can. Sometimes it's a reasonable compromise, serialised objects, mark up snippets and such.
If you don't want to query the document with sql the only benefit is the all in one place thing. ie back up your db, you back up your documents as well, and you can use your db connectivity exclusively.
That said nothing is free, carting all that stuff about in your database costs you.
If you can.
have a documents table, User name for the file, and internal name in your documents directory, so the file name is unique in the file system, and a path description, if there could be more than one.
Then just upload and download the selected document as a file, on a get or set of the related database entity.
You'll need to dal with deployment issues, document directory exists, and the account you are running mysql daemon as can see it, but most of the time, the issues you have keeping documents seperate fromthe db, are much easier to deal with than the head scratchers you are running into now.