Click here to Skip to main content
16,010,392 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Not Able to view the .GML File in the Folder Structure Pin
karthickmani633-Mar-10 18:07
karthickmani633-Mar-10 18:07 
QuestionTextBox needed to be lots of text boxes Pin
offroaderdan3-Mar-10 0:39
offroaderdan3-Mar-10 0:39 
AnswerRe: TextBox needed to be lots of text boxes Pin
Dalek Dave3-Mar-10 1:24
professionalDalek Dave3-Mar-10 1:24 
AnswerRe: TextBox needed to be lots of text boxes Pin
Wayne Gaylard3-Mar-10 1:43
professionalWayne Gaylard3-Mar-10 1:43 
AnswerRe: TextBox needed to be lots of text boxes Pin
Luc Pattyn3-Mar-10 2:12
sitebuilderLuc Pattyn3-Mar-10 2:12 
GeneralRe: TextBox needed to be lots of text boxes Pin
Wayne Gaylard3-Mar-10 3:18
professionalWayne Gaylard3-Mar-10 3:18 
GeneralRe: TextBox needed to be lots of text boxes Pin
Luc Pattyn3-Mar-10 3:29
sitebuilderLuc Pattyn3-Mar-10 3:29 
QuestionDisconnecting from SqlServer Database from VB.net Pin
edmonson2-Mar-10 23:58
edmonson2-Mar-10 23:58 
Hello,

I'am developing an App that needs to access a SqlDataBase named "Work", but this may be located in any drive of my system (C:,D:,U:,...). The database structure is always the same, so I use a unique name and only change the files.

When the application start, I use a OpenFileDialog to locate the database and execute an storedprocedure to attach the database to SqlServer (EXEC sp_attach_db @dbname ...).
This works fine, and I can work with the database.

When the user ends to work with database, I want to detach ("EXEC sp_detach_db) this from my App to allow to choose another location one.
At this point I get an error reporting that the database is currently in use, ans so, it can't be detached.

StoredProcedures form attach and detach owns to Master database, so when I execute it I'am not using my database.

Do you know any procedure to disconnect my App from database using system.data, and then I could execute the detach procedure ?

(If I only execute Attach and Detach, without accessing to database, is runs fine).

Here the Detach function:

Public Function DetachDB(ByVal DbName As String) As Boolean
            Dim Cmd As New SqlClient.SqlCommand
            Dim AffectedRows As Int32
            Dim TmpDbName As String = _DbName
            _DbName = "Master"
            Cmd.Connection = GetConnection
            Cmd.CommandText = "EXEC sp_detach_db @dbname = '" & DbName & "'"
            Cmd.CommandType = CommandType.Text
            Cmd.Connection.Open()
            Try
                AffectedRows = Cmd.ExecuteNonQuery()
                Cmd.Connection.Close()
                _DbName = TmpDbName
                Return (True)
            Catch e As Exception
                If PopupErrors Then
                    MessageBox.Show("[DB]Error separando la base de datos " + e.Message)
                End If
                Cmd.Connection.Close()
                _DbName = TmpDbName
                Return False
                Exit Function
            End Try
        End Function

AnswerRe: Disconnecting from SqlServer Database from VB.net Pin
Eddy Vluggen3-Mar-10 0:08
professionalEddy Vluggen3-Mar-10 0:08 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
edmonson3-Mar-10 0:44
edmonson3-Mar-10 0:44 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
Eddy Vluggen3-Mar-10 1:25
professionalEddy Vluggen3-Mar-10 1:25 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
edmonson3-Mar-10 4:17
edmonson3-Mar-10 4:17 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
Eddy Vluggen3-Mar-10 5:23
professionalEddy Vluggen3-Mar-10 5:23 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
edmonson3-Mar-10 6:32
edmonson3-Mar-10 6:32 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
Eddy Vluggen3-Mar-10 6:47
professionalEddy Vluggen3-Mar-10 6:47 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
edmonson3-Mar-10 7:44
edmonson3-Mar-10 7:44 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
Eddy Vluggen3-Mar-10 10:00
professionalEddy Vluggen3-Mar-10 10:00 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
edmonson3-Mar-10 21:39
edmonson3-Mar-10 21:39 
GeneralRe: Disconnecting from SqlServer Database from VB.net Pin
Eddy Vluggen4-Mar-10 4:15
professionalEddy Vluggen4-Mar-10 4:15 
QuestionNeed help on VB.Net program communicting with website to retrieve data [modified] Pin
orvries2-Mar-10 22:44
orvries2-Mar-10 22:44 
AnswerRe: Need help on VB.Net program communicting with website to retrieve data Pin
Eddy Vluggen2-Mar-10 23:28
professionalEddy Vluggen2-Mar-10 23:28 
GeneralRe: Need help on VB.Net program communicting with website to retrieve data Pin
orvries3-Mar-10 2:09
orvries3-Mar-10 2:09 
GeneralRe: Need help on VB.Net program communicting with website to retrieve data Pin
Dave Kreskowiak3-Mar-10 2:22
mveDave Kreskowiak3-Mar-10 2:22 
GeneralRe: Need help on VB.Net program communicting with website to retrieve data Pin
orvries3-Mar-10 2:38
orvries3-Mar-10 2:38 
GeneralRe: Need help on VB.Net program communicting with website to retrieve data Pin
Eddy Vluggen3-Mar-10 2:22
professionalEddy Vluggen3-Mar-10 2:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.