Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
tools
vsnet.act
vsnet.debugging
vsnet.documentation
vsnet.enterprise.tools
vsnet.general
vsnet.ide
vsnet.jlca
vsnet.servicepacks
vsnet.setup
vsnet.vsip
vsnet.vss
vsnet.vstools.office
vstudio.development
vstudio.extensibility
vstudio.general
vstudio.helpauthoring
vstudio.setup
vstudio.sourcesafe
  
 
date: Mon, 25 Aug 2008 20:18:04 -0400,    group: microsoft.public.vstudio.development        back       


Server Explorer problem   
VS 2005 - windows - vb .net - xp pro

I'm just getting up to speed learning SQL.
I created database in server explorer and added some tables and columns.
Now I'm trying to create tables and columns and insert records etc. from a 
vb .net program.
All is well, I connect to the database and add tables, records etc.
When I add a table and then go to check the results in server explorer and 
then go back and try
something else in the program, it bombs and tells me that it can't open a 
connection b/c another process is using it.
Any subsequent try just says logon failed.
I right click on the database and close the connection in server explorer. 
Still have problem.
I reboot my laptop all is fine, until I look at results in server explorer.
How can I run queries look at results without having to reboot after each 
test?

Some code I've been using, the error comes on Con.open().

Sub ConnectToWebSiteSQLDatabase()
Dim Con As SqlConnection
Dim SQL As String
Dim SqlCon As String = "Server=.\SQLExpress;AttachDbFilename=C:\Program 
Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyFirstDatabase.mdf; 
Database=dbname;Trusted_Connection=Yes;" 'this is the good one that lets me 
create table
Dim cmd As New SqlCommand
Con = New SqlConnection(SqlCon)
Try
    Con.Open()
    'CREATE SQL QUERIES TO ADD-EDIT-DELETE DATA IN SQL DATABASE ON WEBSITE
    'SQL = "CREATE TABLE TonysTable4 (FirstName varchar(15) default NULL, 
LastName varchar(25) default NULL); " 'good one adds table to database
    'SQL = "alter table TonysTable2 ADD Address1 varchar(30), Addess2 
varchar(30);" 'this is a good one that adds columes
    'SQL = "Insert into TonysTable2 (FirstName, LastName) 
values('Tony','Goodguy')" 'good one to insert records
    cmd = New SqlCommand(SQL, Con)
    cmd.ExecuteNonQuery()
    Con.Close()
    Con = Nothing
    MsgBox("Whoo hooo connected")
Catch ex As Exception
    MsgBox(ex.ToString)
End Try
End Sub

Thanks
date: Mon, 25 Aug 2008 20:18:04 -0400   author:   Tony M

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us