Avatar of ygnd
ygndFlag for Israel asked on

Change default path & db in Sql server

Hello to the expert,
Pls advise, How to change the path & db to be the default in sql server 2005 express?
Thanks
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
ygnd

8/22/2022 - Mon
BrandonGalderisi

What do you mean path & db?  Do you mean the default path where databases will be created and the default Db for a user?

To change the default Db for a user:

ALTER LOGIN TheLoginName
WITH DEFAULT_DATABASE = TheDbName
ASKER
ygnd

I have db connect to Visual web developer 2005 express with the connection
Data Source=.\SQLEXPRESS;
AttachDbFilename=D:\ExcelAppl\WizPlan.Web\App_Data\WizPlan.V5.mdf;
Integrated Security=True;
User Instance=True

When I try to run SP from  the sub below, I have connection failure on connection open

Protected Sub DropDownList5_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

Dim ConnString As String = "Provider=SQLOLEDB;
                                             Data Source=LepTop-3\SQLEXPRESS;
                                            AttachDbFilename=D:\ExcelAppl\WizPlan.Web\App_Data\WizPlan.V5.mdf;
                                            Integrated Security=SSPI;
                                            User Instance=True"
                     
Dim sqlConnection1 As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(ConnString)
               
Dim cmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand("SPweb_Load_results", sqlConnection1)

cmd.CommandText = "SPweb_Load_results"
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Connection = sqlConnection1
sqlConnection1.Open()
cmd.Parameters.Add("@prm", 3)
cmd.ExecuteNonQuery()
sqlConnection1.Close()
End Sub

when I use the connection string below, it run ok but it point to other db in
 ---> D:\ExcelAppl\WizPlan\App_Data\WizPlan.v6.mdf

        ConnString = ConnString & "Provider=SQLOLEDB;"
        ConnString = ConnString & "Data Source=LepTop-3\SQLEXPRESS;"
        ConnString = ConnString & "Initial Catalog=WizPlan;"
        ConnString = ConnString & "Integrated Security=SSPI;"
        ConnString = ConnString & "Connect Timeout=30;"
        ConnString = ConnString & "User Instance=false;"
pls advise?
Thanks
ASKER CERTIFIED SOLUTION
BrandonGalderisi

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Raja Jegan R

You can associate the Default Database and Path for the user associated with:

Go to security --> Users and select the particular user used for that particular application.

Set the default database for the particular user and I hope this resolves your issue.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
ygnd

Hi BrandonGalderisi's
This is the err, I get with the new connection string
Unable to open the physical file "D:\ExcelAppl\WizPlan.Web\App_Data\WizPlan.V5.mdf". Operating system error 32: "32(error not found)".
Ygnd
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
ygnd

The problem, not solved.
I will work on it later.
Thanks
Mark Wills

Interesting. Seems that the database name is "Wizplan" in the instance LepTop-3\SQLEXPRESS;"  at least that is what is seems to be to get V6 - what is the difference between V6 and V5 and how do the databases appear in SSMS ?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mark Wills

Gosh, that was quick to accept... Especially when problem was not solved ;)
ASKER
ygnd

Hi mark,
Thank you for your comment.
The question closed because technical problem with the sql setup.
I will rase it again after fixing problems & I will be glad to get your help, too.
Thanks
Ygnd