VS 2010 Read SpecialFolder In Connectionstring From XML?
Aug 12, 2011
I'm having a small problem which I can't seem to solve. I have an XML-file with a path to the database, which the user can change via the application.The standard path is the MyDocuments folder, but I can't seem to connect to the database when I use that in the node.xml:
<db_path>Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & " est.sdf"</db_path>
connectionstring: Dim strConn As SqlCeConnection = New SqlCeConnection("Data Source=" & Replace(myxmlfile.Descendants("db_path").Nodes(0).ToString(), "&", "&"))
my application uses a login form to connect to a remote SQL database, which uses SQL authentification. Normally, I define a connectionstring at design time which I complete with the username and password at run time.I now need to implement a ReportViewer which needs a connectionstring. I want it to use the existing connection however it obviously does not see the coded connectionstring, so I decided to add the connectionstring in app.config.
Everything is fine except the underlined code says-'Expression is of type 'System.Environment.SpecialFolder', which is not a collection type.' All I want to do is add the node to the treeview. Let's say that I want "My Program" to be the node in the treeview, and THAT node is a folder inside my program files, which also has a folder inside of that which is called "Projects".[code]
I'm trying to make a program that can read .mp3 data (Such as Artist, Album, Year, Track number, etc), but I need to be able to do two things that I have no clue how to do:
1. Read starting from a specified string (E.G, On one line it states: [code]
2. Read until a specified string (E.G, On the previously stated line,I need to read starting from what I said, up until.
I use dbf files from db2k in my application.When I try to connect, it takes a long time and I find the application exited without any error msg.The connection string I use:Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\agbvseng01APPLISNomenclature_Eng_Bvs;Extended Properties=dBASE IV" Data source is on a server.I dont know why this happens.
I designed a DAL (data access layer). This DAL mainly consists of a handfull of methods to call stored procedures. All methods are shared. So no instance generation of the DAL class occurs.
The DAL with it's single class is located in an own project. The connection string is defined in the app-config file of this project.
I want other applications to use the DAL class by referencing the dll generated by the DAL-project. For this reason, I can not any longer define the connection string in the DAL app-config as it is, because the client application determines which database needs to be used.
- Dropping the "shared" keyword of my methods. Create an instance of the DAL class. Add a property for the connection string. When application starts, create one global or multiple local instance/s of the DAL and set it's connection string property.
Comment: I don't like this, because it implies more coding work on the application code side (create instance of class, assign connection string)
- Granting the DAC class access to the connection string defined in the application code by adding a connection string property inside the application code. Thus the DAC class remains "shared".
Comment: I'd need to set a reference from the DAL to the application code during without knowing the application yet. I could try stack tracing or something like that. But it feels to convoluted for me.
I'm merging two of my projects that can share a lot of the same classes into one solution with two web applications and a shared class library.
I've literally just dumped all the classes into the class library project and as expected I've got a ton of errors to fix. My main problem at the moment is the connection string. Currently I have this (which is obviously not going to work):
''' <summary> ''' Initialise the data access layer by loading the database connection string from the Web.Config file
I've looked at a lot of posts on different forums where others have received the same error. Most say they were not referencing the connectionstring from the web.config file correctly, or they were trying to open the connection before setting the connectionstring. Well, if that were the case for me, then how does it work on two different systems, but not on the third? It works on my development PC and on the development server, but not in the production environment. The difference is the web and DB server are separate physical servers in my production environment and on a single server for development. My setup, error message and code will be listed below.
I can simulate the error on my PC if I rename the connection string in either section of the web.config file (appsettings, connectionstrings) to something else. You will see how I have tested both below.
I know below code causes an error since "Property 'AAConnectionString ' is 'ReadOnly". What other choice do I have to assign a value for a user ID or a password with a value of textbox by coding?
I create project in my pc with vb.net and sql database when i tried to run this project to another pc there is error occurred that the connectionstring has not been initialized. I really troubled this from last one week to solve the problem. how to change the connectionstring on client pc at runtime or any other way to create a connectionstring that has auto detect in any pc where the program is installed.
Im writing a app using vb.net, which has multiple front ends e.g a windows service and a windows forms app. Ive got all my business logic and database stuff compiled into 1 project (producing a dll) then the different front ends as different projects calling the dll.
In the backend / dll project Im connecting to 2 databases using app.config to store the connection strings and DataSets / TableAdapters. This all works fine .... Until
When I deploy the windows app, it deploys the exe and the dll produced by the backend project. when its installed on a client PC, Im need to point the app at a different db server and therefore need to change the connectionstring, but its packaged up in the dll.
is there any way I can use a settings file within my windows app (therefore deployed with my windows app) where I can define the connectionstring, which onload gets passsed through into my dll, so the backend connects the correct database. I know how to pass standard settings through (strings etc) but the my.settings.connectionstrings seem to be readonly.
I have a web application that works perfectly on my local machine but not once Ive uploaded to the hosting server I get: Server Error in '/' Application. The ConnectionString property has not been initialized. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized......
I have a web application that works perfectly on my local machine but not once Ive uploaded to the hosting server i get:Server Error in '/' Application.The ConnectionString property has not been initialized.Description: An unhandled exception occurred during the execution of the current web request.review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.Source Error:Line 423:Dim conn As New SqlConnection(connstring)
When I add a datasource via the wizard the connection string is either writen directly in the dataset.designer or there is a reference to the projects settings. Either way I am figuring out if I could change it dynamicaly when my app starts up ?
I have created a program using VB2008 it has two forms that I am having a problem with FORM2 has a textbox and a button that I use to pass a string to the code in FORM3 that is used to populate DATAGRIDVIEW1. I am using MS ACCESS 2007 for my database. I have supplied the code I am having trouble with below. When I run the program and type a string into the textbox and press the button I get this error: oledbException was unhandled: No value given for one or more required parameters. The area that was highlighted was m_daDataAdapter.Fill(ds). How can I get this code to populate the
i have visual studio 2008 in with i'm doing an ASP.NET application.Now i want to link my pages to SQL Server 2008. On my page default.aspx, I put a gridview and then i can find the connection string from there to the sql server db, which i can then put in a class and have all pages use it.Is this the only way to find the connection string for any servers on the network or are there other ways (probably better ways of finding the conn string?)
I am having an issue using a datagrid. I can use it fine on my development machine in VB 2005. But, when I deploy it to a client and they try to access the datagrid this message comes up:To run this example, replace the value of the connectionString variable with a connection string that is valid for your system.
Both machines are running Windows XP Pro (SP3). Is there some type of assembly for datagrids that I am missing in my application or some prerequisite that I need to install as part of the solution.
I would like to save my connectionstring in my.settings but this property is only readonly.When i would save it as a String, then I can't find it with the wizard for building a report. [code] is there also another way to build a connectionstring? this works, but the type of My.Settings. Data base String is a string and not a ConnectionString.
I'm trying to use an 'SQL Express' (or is it SQL Compact?) .MDF file as the datasource on a simple website using a Chart control.
Locally, it works great; but only if the 'AttachDbFilename' has the full path. Am I messing something up, or does it really need to be full path? If so - how do I accomplish this without using something like Server.MapPath()?