Hi all,
I use Visual Studio 2005 Pro. I have a problem with the connectionstring as it changes after I close and reopen the program. The first time it works fine, but after that I get an error message saying:
The (Database) already exists. Choose a different database name.
I really can not understand why? Why it connected the first time? What does this message mean? and How can we go around this problem?
Connectionstring Problem
Started by
Guest_mohamedsaleh70@hotmail.co_*
, Apr 13 2007 05:01 PM
3 replies to this topic
#1
Guest_mohamedsaleh70@hotmail.co_*
Posted 13 April 2007 - 05:01 PM
Guest_mohamedsaleh70@hotmail.co_*
|
|
|
#2
Posted 14 April 2007 - 09:07 AM
#3
Guest_mohamedsaleh70@hotmail.co_*
Posted 15 April 2007 - 06:40 AM
Guest_mohamedsaleh70@hotmail.co_*
Void said:
It seems like you are not disconnecting. Do you have a disconnection line?
Thank you very much for your care and time. Here is a sample of my code.
' Create the connection string and populate the data table
' with data.
Dim connectionString As String = "Integrated Security=SSPI;" & _
"Persist Security Info = False;Initial Catalog=Northwnd;" _
& "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\SQL Server 2000 Sample Databases\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"
Dim connection As New SqlConnection()
connection.ConnectionString = connectionString
Dim employeeAdapter As New SqlDataAdapter _
(New SqlCommand("Select * from Employees", connection))
connection.Open()
employeeAdapter.Fill(employeeTable)
' Set the DataSource property of the BindingSource to the employee table.
bindingSource1.DataSource = employeeTable
' Set up the binding to the ReportsTo column.
Dim reportsToBinding As Binding = _
textBox2.DataBindings.Add("Text", bindingSource1, "ReportsTo", _
True)
' Set the NullValue property for this binding.
reportsToBinding.NullValue = "No Manager"
' Set up the binding for the PictureBox using the Add method, setting
' the null value in method call.
pictureBox1.DataBindings.Add("Image", bindingSource1, "Photo", _
True, DataSourceUpdateMode.Never, _
New Bitmap(GetType(Button), "Button.bmp"))
' Set up the remaining binding.
textBox1.DataBindings.Add("Text", bindingSource1, "LastName", True)
End Sub
#4
Guest_Jordan_*
Posted 15 April 2007 - 08:57 AM
Guest_Jordan_*
Try adding
connection.Closebefore your end sub.


Sign In
Create Account

Back to top










