Hi all,
I'm wondering is it possible to create a new column to an existing database using vb .net 2008 express and SQL CE version?
I've tried with these codes below with no success
If there is something I did wrong please correct me.Code:If TextBox1.Text = "" Then MsgBox("Enter Column Name", MsgBoxStyle.Question, "Add Column") Else Dim str_addcolumn As String Dim com_addcolumn As New SqlServerCe.SqlCeCommand Dim adp_addcolumn As New SqlServerCe.SqlCeDataAdapter Dim con_addcolumn As New SqlServerCe.SqlCeConnection con_addcolumn.ConnectionString = My.Settings.CBDesignProgramConnectionString str_addcolumn = "ALTER TABLE GeneralNF ADD " & TextBox1.Text & " NVARCHAR(100)" com_addcolumn = con_addcolumn.CreateCommand com_addcolumn.CommandText = str_addcolumn con_addcolumn.Open() Try com_addcolumn.ExecuteNonQuery() con_addcolumn.Close() Catch ex As Exception MsgBox(ex.Message) con_addcolumn.Close() End Try End If![]()
Thanks in advance.




Reply With Quote