Hello,
After installing SQL Express server, I need to create the main database, without the Management Studio Express.
Is it posible?.
Thank you so much.
Try
oCn := CREATEOBJECT( "ADODB.Connection" )
Catch
Saying := "Could not create an ADO COnnection"
MsgInfo( Saying )
oDLG:End()
Return(.f.)
End Try
// assumes database has been created
// and you want to add tables
TRY
oCn:Open( xCONNECT )
CATCH oErr
Saying := "Sorry .. It does not appear the database "+xCatalog+chr(10)
Saying += "Exists on Sql Server "+xSource+chr(10)
Saying += "Please contact your Sql Server DBA"+chr(10)
MsgInfo( Saying )
oDLG:End()
RETURN(.F.)
END TRY
oCn:Close()
oCn := nil
oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
// check for very first table
cSQL := "SELECT * FROM USERINFO"
TRY
oRs:Open( cSQL, xCONNECT )
CATCH oErr
Saying := "WARNING .. the Database File "+xSource+chr(10)
Saying += "appears to exist, however the Tables have not been created"+chr(10)
Saying += "If this is your First time using this Program ..."+chr(10)
Saying += "Please proceed, otherwise contact your Administrator"+chr(10)
Saying += " "+chr(10)
Saying += "Do you wish to proceed to create the NEW Database Tables ?"+chr(10)
If MsgNoYes( saying )
lCreate := .t.
Else
oDlg:End()
Return(.f.)
Endif
End Try
oRs:CLose()
oRs := nil
lCreate := .f.
End Case
If lCreate = .t.
// create tables
Try
oCn := CREATEOBJECT( "ADODB.Connection" )
Catch
MsgInfo( "Could not create the ADO object for connection")
oDLG:End()
Return(.f.)
End Try
TRY
oCn:Open( xCONNECT )
CATCH oErr
MsgInfo( "Could not open a Connection to Database "+xSource )
oDLG:End()
RETURN(.F.)
END TRY
cSQL := "CREATE TABLE UserInfo"
cSQL += "( "
cSQL += "[USEREID] char(18) NOT NULL, "
cSQL += "[USERID] char(25) NULL, "
cSQL += "[LNAME] char(15) NULL, "
cSQL += "[FNAME] char(1) NULL, "
cSQL += "[READONLY] char(1) NULL, "
cSQL += "[WRITEONLY] char(1) NULL, "
cSQL += "[SUPER] char(1) NULL, "
cSQL += "[ADMIN] char(1) NULL, "
cSQL += "[ENTRYBY] char(25) NULL, "
cSQL += "[ENTRYDATE] DATETIME NULL, "
cSQL += "[LASTLOG] DATETIME NULL, "
cSQL += "[PASSWORD] char(16) NULL, "
cSQL += "[UPDATED] SMALLINT DEFAULT 0, "
cSQL += "CONSTRAINT PK_USERINFO PRIMARY KEY ( USEREID )"
cSQL += " )"
// create the table Userinfo
// with primary key
Try
oCn:Execute( cSQL )
Catch
MsgInfo( "Create Table USERINFO Failed" )
oDLG:End()
Return(.f.)
End try
cSay := "Created Table Userinfo"
oSay:ReFresh()
SysReFresh()
oCn:Close()
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 40 guests