James
asked on
Altering a MSSQL table from Microsoft Access via DAO
I have a support database in Access that I've used for years to alter the structure of a MSSQL database. Up until now, the code used ADO to do that but, thanks to some internal IT changes at my client, ADO is no longer allowed. They are insisting on DAO.
Here's the original ADO code. In this example, it is changing the length of field PONumber in table tblOrders to 20.
-------------------------- ---------- ---------- ---------
Private Sub cmdAlter_Click()
Dim strSQL As String
Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
oConn.Open "Driver={SQL Server};" & _
"Server=" & Me.servername & ";" & _
"Database=" & Me.databasename & ";" & _
"Uid=" & Me.username & ";" & _
"Pwd=" & Me.password & ""
strSQL = "ALTER TABLE dbo.tblOrders ALTER COLUMN PONumber nvarchar(20)";"
oConn.Execute strSQL
oConn.Close
End Sub
-------------------------- ---------- ---------- ---------
Can the same thing be done in DAO?
Thanks!
James
Here's the original ADO code. In this example, it is changing the length of field PONumber in table tblOrders to 20.
--------------------------
Private Sub cmdAlter_Click()
Dim strSQL As String
Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
oConn.Open "Driver={SQL Server};" & _
"Server=" & Me.servername & ";" & _
"Database=" & Me.databasename & ";" & _
"Uid=" & Me.username & ";" & _
"Pwd=" & Me.password & ""
strSQL = "ALTER TABLE dbo.tblOrders ALTER COLUMN PONumber nvarchar(20)";"
oConn.Execute strSQL
oConn.Close
End Sub
--------------------------
Can the same thing be done in DAO?
Thanks!
James
Why not use a pass-through query?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.