Link to home
Start Free TrialLog in
Avatar of Moe DeShong
Moe DeShongFlag for United States of America

asked on

Changing database structure in vb.net

I need a resource that shows how to add/remove/change tables fields and most importantly relationships in an access database using vb.net.
Avatar of andycwk
andycwk

Try this as a starter
All you need is a connection to the database and then basic T-SQL syntax:

  Dim myScalarQuery As String = "ALTER TABLE Table1 ADD Field4 VARCHAR(20) NULL"
  Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='<path to access db>';User Id=admin;Password=;"
  Dim myConnection As New OleDb.OleDbConnection(myConnectionString)
  Dim myCommand As New OleDb.OleDbCommand(myScalarQuery, myConnection)
  myCommand.Connection.Open()
  myCommand.ExecuteNonQuery
  myConnection.Close()

The above example adds a text field to an already created table.

As for relationships I'm not sure if you can create them with T-SQL. Alternatively you can use the Access Object adding a reference to the Microsoft Access Object Library.


Avatar of Moe DeShong

ASKER

jerete,
I really need to know how to alter the relationship to award the points.  I am trying to get rid of the autonumber fields and replace them with GUID fields which will require me to change the relationship.  Thanks for the input
ASKER CERTIFIED SOLUTION
Avatar of jerete
jerete

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial