|
-
May 18th, 2013, 08:08 AM
#1
Thread Starter
New Member
Connection string data source name
I have written my first app using a database. One of my connection string is as follows,
m_cn1.ConnectionString = "Data Source=.\SQLEXPRESS; AttachDbFilename = " & _
m_cn1mdfPath & ";Integrated Security=True; Connect Timeout=30;" & _
"User Instance=True"
I have installed this app on a few computers and all works well, but one.
My data source name on that PC is "SDCO".
My question is, is there a way to determine what the datasource name is and assign it to a string?
something like
public condatasourcename as string = my data source name on this PC
m_cn1.ConnectionString = "Data Source=.\" & condatasourcename & ; AttachDbFilename = " & _
m_cn1mdfPath & ";Integrated Security=True; Connect Timeout=30;" & _
"User Instance=True"
-
May 18th, 2013, 09:07 AM
#2
Re: Connection string data source name
Not automatically... you could even have multiple instances on the same computer... I have three.... SQLEXPRESS, SQLServer200R2 and SQLServer2012 .... I *think* you can use SQL DMO to iterate the instances on the machine, put them into a dropdownbox, then have the user select which one to use... I think. You would need to look it up and experiment some.
-tg
-
May 18th, 2013, 10:25 AM
#3
Thread Starter
New Member
Re: Connection string data source name
Well that blows. I do not want the operators to have any interaction with the setup of this interface. What about something along the lines of;
public conName1 as string = "SDCO"
public conName2 as string = SQLEXPRESS"
etc....
if m_cn1.ConnectionString = "Data Source=.\" conName1 exists
m_cn1.ConnectionString = "Data Source=.\" & condatasourcename & ; AttachDbFilename = " & _
m_cn1mdfPath & ";Integrated Security=True; Connect Timeout=30;" & _
"User Instance=True"
else if m_cn1.ConnectionString = "Data Source=.\" conName2 exists
etc....
end if
any examples?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|