Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I added a column to a table, but, I can't see it.

Status
Not open for further replies.

furjaw

Programmer
Mar 27, 2006
49
0
0
US
I ran the code below that adds a column to an SQL table.
I refreshed Data Sources, but, the new column does not appear.
I refreshed Server Explorer and the new column does not appear.
I tried running the code again and I got:
"Column names in each table must be unique. Column name 'CaseNbr' in table 'Patient' is specified more than once."
so the column did actually get added, but, I can't see it.

Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlConnection As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Patient.mdf;Integrated Security=True;User Instance=True")
Dim str As String = "ALTER TABLE Patient ADD CaseNbr Varchar(50)"
Dim command As New System.Data.SqlClient.SqlCommand(str, sqlConnection)
sqlConnection.Open()
command.ExecuteNonQuery()
sqlConnection.Close()
Close()
End Sub
End Class
 
I ran into this yesterday, not sure if what I did will work. In my case I was using Enterprise Manager and I added a table to a database. I refreshed EM about 5 times and the table still didn't show up. I could run queries on it so I knew it was there. It ended up I had to close EM and reopen it.

I'm just saying if you hadn't already tried, maybe closing Server Explorer and reopening it will show the refreshed data.

[monkey][snake] <.
 
I can confirm with monksnake, I had the same thing a few weeks back, very weird. I closed and reopened, worked for me.

Michael
 
>what version sql you are using?

I am using SQL Express that came with Visual Studio 2005 Professonal.

Microsoft SQL Server Management Studio Express 9.00.3042.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 7.0.5730.11
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top