.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

sql connection string from textbox

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :Sql Server

How can I get a connection string from a textbox at run time?

ex. "Data Source=,<server name>;Initial Catalog=<database name>;Integrated Security=True;Pooling=False"

I use it as a literal(with @"....) at design time and it works but I want to read it from a textbox...


Thank you

adrian socolescu

View Complete Post

More Related Resource Links

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

Modifying connection String in Web config using Install Wizard



Im trying to create a Web Deployment Project, the built in setup and deployment is very good in Visual Studio, i need to able to add an additional step in the setup to change the connection string in the Web config file. Ive seen a lot of articles on how to do this and in particular this http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx#7162670 I am however stuck on the final part of this tutorial, im using the code Scott provided but have two errors,  heres part of my code where the errors are

using System;
using System.Configuration;
using System.Configuration.Install;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.DirectoryServices;

 void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
            // Retrieve "Friendly Site Name" from IIS for TargetSite
            DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSit

Need help with validating an alphanumeric string within a textbox control.

Hi everyone,I am developing a simple WinForms app for a presentation next week and need to validate that a particular string in a particular textbox is alphanumeric.  I have included the code from the button click event handler below: // Alphanumeric private void btnValidate4_Click(object sender, EventArgs e) { try { if (txtAlphanumeric.Text == "") MessageBox.Show("Please enter an alphanumeric string before clicking the 'Validate' button.", "Whoa there, pardner!!", MessageBoxButtons.OK, MessageBoxIcon.Information); else { Regex rgxAlphanumeric = new Regex("^[a-zA-Z0-9]*$"); Match alphaNumericMatch = rgxAlphanumeric.Match(txtAlphanumeric.Text); if (!alphaNumericMatch.Success) MessageBox.Show("The string supplied does NOT match the specified pattern.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); else { MessageBox.Show("The supplied string matches the specified pattern.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

How do I set a string in a textbox to unicode?

I have a report requirement to embed the fonts when the report is exported to PDF. The report server is  SSRS 2005 SP3 and upgrading to SSRS2008 is not an option. I have validated that all requirements have been met to ensure embedding have been met except one -  "The characters in the string that has the Font property set are Unicode, not ANSI. No font embedding occurs for ANSI characters." I referenced this article for requirements -  http://technet.microsoft.com/en-us/library/ms159713.aspx . My data is in a dataset field that was populated by a stored procedure. When I examine the rdl the it has a type name of System.String (<rd:TypeName>System.String</rd:TypeName>) How can I ensure that any strings in the report are recognized as unicode? The SSRS PDF renderer must be interpreting the strings as ANSI because that's how they are being rendered in the PDF file preventing embedding. Any assistance would be greatly appreciated!

Custom security via connection string

Hi Is it possible to pass information into the SQL Server relational engine via the connection string in the same way as it can be done for Analysis Services? I need to generate a user context for a forms authentication application (i.e. no windows user accounts). SSAS allows you to pass in a list of database roles or a customdata parameter on the connection string. These can be used inside the database in lieu of a windows identity. I am wondering if there are equivalent parameters available for the SQL connection string.  I guess that I could create SQL logins from each of the forms users with a system generated password and then pass the uid and password on the connection string but this seems unnecessarily complicated. Andrew Wiles - www.it-workplace.com - MDX made simple

connection string

on the computer with sql management installed i use this and it works(server name):  .\SQLEXPRESS the computer name is: MAINCOMPUTER2 another computer on the network would use what? i can see  the c drives on either computer from either computer so i am connected.    

Connection string

Hi There!I am doing a project using Visual Web Developer Express. I have built a database using MS SQL Server Express which I have installed together with Visual Web Developer Express. Please help me what sort of the connection string I should use in the pages of my website to establish connection to the database.Thank you

problem in connection string

i have problem in connection strin i host my siteand database is in DATA DIRECTORYmy site run successfully in offline but an error of connection string in online pls give me an example of string for onlinei use asp.net, C# and sqlserver 2005

How to change connection string of a pivot table pointing to SSAS 2005 cube using excel 2003?

Hi All,I am not sure if I should have posted this query to Excel 2003 forum. But posting it here as it applies to SSAS 2005 as well.Ok, let me give the background before I tell the actual problem.We have users on ABC domain and the SSAS server is also on ABC domain. Users on this domain can acess the excel pivots by connecting to cube to browse the data. They leave the Userid & password field blank while they setup the connection string and it works fine. Thanks to windows authentication that takes the credentials of user logged in. Let's say I have two users A and B, they login to ABC domain with their own windows ids.  Now when user A creates a excel file having a cube pivot and then sends this file to user B, user B can refresh and modify the same excel file (he can select new measures to pivot, new hierarchies in filters and so on).Now, let's say I have another user, user C. He has excel 2003 installed on his PC and cannot migrate to excel 2007. He is on different domain XYZ but have a valid windows userid on domain ABC. The domain ABC & XYZ can not be setup to have trusted relationship. Now, when user A sends the same excel file to user C. When user C opens the file and try to refresh it or try to modify the pivot by selecting/deselecting any elements, he gets below error prompt:" An error was encountered in the transport layer." and "Errors in the

Url String in textbox

how do i get my textbox to display my url string when the webbrowser has loaded a page. like in internet explorer? (wpf C#)

Writing connection string in web.config file by code or dynamically

I want to write connection string in web.config file of my application by code. If anyone know the way or code just help me..NET,C#,SQL SERVER

help configure my connection string

i have created a linq to sql mapping classnow i changed the location of the server but i can't chane the connection string to the new location where can i do this ?HosDataContext db = new HosDataContext();             Sur_Accessory nor = new Sur_Accessory             {                 SurgeryAccessoriesID = Guid.NewGuid(),                 Kind = TextBox4.Text             };HosDataContext db = new HosDataContext();            Sur_Accessory nor = new Sur_Accessory            {                SurgeryAccessoriesID = Guid.NewGuid(),                Kind = TextBox4.Text            };this code brought error after changing the serverError 8 The type or namespace name 'HosDataContext' could not be found (are you missing a using directive or an assembly reference?) E:\WorksAndBackUps\Hospital\4-9-2010\MostafaRadyHospital\MostafaRadyHospital\Admin\Surgery\UCA_SurgeryRoom.ascx.cs 34 37 MostafaRadyHospital

Passing String to Rdlc's TextBox

Hello  I am pretty new to reporting services. Now i have something like this. on the .cs file, i have a fullName lets say String fullName = "John Smith", Now I want to pass this string to the report's textBox and show this value on this textbox.   How can i do this? 1.How should i write in .cs file? 2. How should i set the expression for the textbox?   Thank you very much. It is very urgent! Please help!

Conversion from type 'TextBox' to type 'String' is not valid

I have a FormView that allows a user to register for a company event. I want to do a couple of things with this form. 1. I need to write this data to a MS SQL database 2. I need to send an email confirmation of their registration to their email. I know how to do both of these things, but i am having trouble doing both at the same time. It would be nice if I could do it in one click, but I coded it into two pages to try to help simplify it. The first page allows the user to input their information into a formview and when they click the submit button, it places those answers into session variables:Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Session("FirstName") = Me.FormView1.FindControl("FirstName") Session("LastName") = Me.FormView1.FindControl("LastName")  <li> <label> First Name</label> <asp:TextBox ID="FirstName" runat="server" class="text-box" Text='<%# Bind("FirstName") %>' /> </li> </ul> </div>

Connection String of ActiveDirectoryMembershipProvider that points to servers of High Availabilty

I have 2 LDAP servers, A and B which are configured to high availability. When A fails, B will take over and vice-versa. How do I set the connection string of the ActiveDirectoryMembershipProvider in this case? Thanks in advance.   (P.S: I am using asp.net / VB.net, .net framework 2.0) 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend