index > .NET Framework Data Access and Storage > i need help with passing parameters in the connectionString

i need help with passing parameters in the connectionString

i'm wanting to pass the values of 2 textboxes in a form in the connectionstring as uid and pwd. i've already created a new Login in SQL Server but when i'm passing the textBox1.text and the textBox2.text with the & concatenate operator the compiler yells at me

this is the code in my app.Config file where i stored the connectionstring

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key ="connectionString" value="Address=valid ip addess;Trusted_Connection = true; Database=Northwind; uid=" & textBox1.Text & "; pwd=" & textBox2.Text & " " />

</appSettings>

</configuration>

An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll

Additional information: The '&' character, hexadecimal value 0x26, cannot begin with a name. Line 4, position 115.

i desired each user of this application to authenticate against SQL Server and be granted access to their schema

please i need help

thanks

guyndjeng

Hi,

You can not have a TextBox instance value inside a connection string in a configuration file. You have to add pair values to pick up data from there, and in case you need to ask for some of those values to the user, you have to create the connection string based on those values

For storing and retrieving connection strings from config files check out this link

 And for building connection strings use the ConnectionStringBuilder. Check that info in this link too.

Best Regards




Diego Rojas.
Luis D. Rojas

Thank you very muc Luis for your insight i'll start looking on that rightaway..

best regards...

guyndjeng
reply 3

You can use google to search for other answers

 

More Articles

• delete row is not updating in dataAdapter
• Creating Access-Table with DEFAULT value in Column
• international character support in ms access
• Connection problem to an Excel File with ado.net (OleDb.OleDbConn...
• Processing 'text' files, fixed width, .CSV, TAB or other delim
• System.Security.AccessControl Namespace
• can't insert data into database
• Design Issue: Multiple definitions of db in separate prjcts. Agg...
• Query a View
• Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Copying tables from a dataset to a SQL T
• Inserting a row duplicates this row
• Advice needed - persist data during a se
• Temp tables in Stored Procedure
• How do I display the Connection string b
• Update SQL database...Please help
• Can a DataSet tell if tables in the SQL
• SQL Server Procedure call timeout from .
• What is the best way to handle null valu
• Reference to a field after record search
• Any way to display images in gridview?
• Update unable to find TableMapping error
• Navigating Large Database
• DataSet or DataReader
• Display autonumber

Hot Articles

• OleDbPermission
• Unable to Update/Insert a new row into t
• Currency data / Bound field in a Datavie
• Expression Building - Access 2003
• How To Store Products with Attributes
• Problems with running an Access macro in
• Problem in element order - while writtin
• ADO.Net Performance
• Ado.Net 2.0 Provider compliance?
• How to get a file stored in an Access da
• Excel Query: Can You Query Which Columns
• Internal .Net FrameWork Data Provider Er
• TransactionScope
• ExecuteNonQuery not working within CLR S
• Connecting SqlExpress from .net 1.1

Recommend Articles

• SqlException: Data has been modified by
• no option to connect system.data.oledb
• Rollback during Thread.Abort exception o
• Personalization & Integrated Security
• I had the same problem
• Determination of Business Logic location
• How do I display the Connection string b
• DataTable select problem!!!!!!!!!!!!!
• SQLDataSource
• How Do I Load MySQL DB Data
• Data Access Page
• Problem | Oracle 9i Release + With Vb.Ne
• can we call myDataSet.AcceptChanges befo
• How can I save textbox with value in the
• Import Excel sheet using ASP.net web app