By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

Is it possible to use a variable for a SqlConnection string

P: 5

I'm new to VB.NET. I am creating a windows form app where a user will be presented for credentials (server, database, user id, password) to connect to a SQL Server database. I am having the users enter these through TextBoxes. Is it possible to pass the TextBox's Text property to the SqlConnection string?

I've tried something along the lines of:

Expand|Select|Wrap|Line Numbers
  1. Dim objConnection As New SqlConnection("server=" & txtServer.text & ";database=" & txtDatabase.text & ";user id=" & _
  2.                                            txtUserName.text & ";password=" & txtPassword.text)
But believe I am way off.

Apr 19 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.