473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is it possible to use a variable for a SqlConnection string

5
Hello,

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.

Thanks!
Apr 19 '12 #1
0 1032

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

Similar topics

0
by: Onder Kaya | last post by:
We have Windows NT 4.0 Oracle 8.1.7 and ORACLE ERP 11.5.8 We created new discrete job. This discrete job contains material requirements and we have custom form which is haz.issue. This form...
8
by: Kamil Grymuza | last post by:
Hi Is it possible to have a name of enumerated value in string somehow? enum { ID1 = 1, ID2=2, } And can I somehow make something like cout<<ID1<<endl; and heve printed "ID1" not 1?
5
by: MLH | last post by:
I'm working with lots of long strings now, it seems. I have to import them & parse them constantly. The A97 memo field type supports only 32768 chars. What happens when this is processed... Dim...
3
by: djozy | last post by:
I want to make asp.net application in C# that is connected with SQL Server database. When I put this connection string: SqlConnection conn = new SqlConnection( "user id=;" +...
0
by: MattC | last post by:
I'm trying to store my sqlconnection string in the registry but all I have found is aspnet_setreg which only stores the username and password, I want to store the entire string. I then found I...
3
by: moondaddy | last post by:
How can I create a public variable similar to an Enum, but rather than returning integer values it would return String values? -- moondaddy@nospam.com
45
by: Zytan | last post by:
Shot in the dark, since I know C# doesn't have macros, and thus can't have a stringizer operator, but I know that you can get the name of enums as strings, so maybe you can do the same with an...
0
by: Yasin cepeci | last post by:
is it possible that read string values in a filled dataset?
1
by: trandel | last post by:
Hi I am a newbie to .NET and C# I have been asked to maintain a website for a client and am having a problem with an SQL Connection. The error I get is on a page that displays the result of a...
9
by: Slickuser | last post by:
Hi, I'm trying to use my variable in another variable. How can I achieve that? I can use + (concat) but it will be a lot me to concatenate. I have to use 3 variables with 15 replacement. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.