Does anyone know how I can update the column properties in Access from VB.NET?
I am trying to make the column a check-box after I create the column.
Here is my code:
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Test.accdb;Persist Security Info=False;"
sql = "ALTER TABLE TestName ADD COLUMN [Name] TEXT(255)"
Cmd = New OleDbCommand(sql, con)
con.Open()
ObjCmd = New OleDbCommand(sql, con)
Try
ObjCmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, vbExclamation)
Exit Sub
End Try
con.Close()
sql = "ALTER TABLE TestName ADD COLUMN [TestFlag] YesNo"
Cmd = New OleDbCommand(sql, con)
con.Open()
ObjCmd = New OleDbCommand(sql, con)
Try
ObjCmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, vbExclamation)
Exit Sub
End Try
con.Close()
The columns get added to the database successfully, but I now want to make the 'TestFlag' column a check-box.
In vb code, I would use this:
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim DB As Database
Set DB = CurrentDb
Set tdf = DB.TableDefs("TestName")
Set fld = tdf.Fields("TestFlag")
Set prp = fld.CreateProperty("DisplayControl", dbInteger, 106)
fld.Properties.Append prp
Does anyone know how to do this from VB.NET?
I'm well and truly stuck...
I am trying to make the column a check-box after I create the column.
Here is my code:
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Test.accdb;Persist Security Info=False;"
sql = "ALTER TABLE TestName ADD COLUMN [Name] TEXT(255)"
Cmd = New OleDbCommand(sql, con)
con.Open()
ObjCmd = New OleDbCommand(sql, con)
Try
ObjCmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, vbExclamation)
Exit Sub
End Try
con.Close()
sql = "ALTER TABLE TestName ADD COLUMN [TestFlag] YesNo"
Cmd = New OleDbCommand(sql, con)
con.Open()
ObjCmd = New OleDbCommand(sql, con)
Try
ObjCmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, vbExclamation)
Exit Sub
End Try
con.Close()
The columns get added to the database successfully, but I now want to make the 'TestFlag' column a check-box.
In vb code, I would use this:
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim DB As Database
Set DB = CurrentDb
Set tdf = DB.TableDefs("TestName")
Set fld = tdf.Fields("TestFlag")
Set prp = fld.CreateProperty("DisplayControl", dbInteger, 106)
fld.Properties.Append prp
Does anyone know how to do this from VB.NET?
I'm well and truly stuck...
