Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2007, 02:58 AM
Authorized User
 
Join Date: Mar 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default I added a column to a table, but, I can't see it.

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=|DataDirector y|\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
 
Old July 3rd, 2007, 09:24 PM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

There are two ways I've found to get new column(s) to appear in the DataSet Designer.

1) Right-click on the table, choose Add Column and type in the information.

2) Delete the table from the Designer. Then right-click on an empty spot and choose Add Table Adapter.

If you find another/better way, please let me know. I'm tired of fighting with the Designer.

Karen






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get texboxes data & added from table dynami venkatmakkena C# 0 August 2nd, 2006 06:41 AM
getting identity column from the table g_vamsi_krish SQL Server 2000 1 March 15th, 2006 05:05 PM
Column position in table kasanar SQL Server 2000 7 June 2nd, 2005 02:00 AM
how to make column of table 1 = to column of table gilgalbiblewheel Classic ASP Databases 4 October 11th, 2004 11:57 PM
how to added a calculated field in pivot table ndenhere BOOK: Access 2003 VBA Programmer's Reference 0 May 27th, 2004 02:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.