Avman9000 Posted February 11, 2008 Share Posted February 11, 2008 I use a Program called "All My Movies." This program is a convenient way to organize my movie titles. I can open the database file in Microsoft Access. I want to be able to add a movie title to the column titled "originalMovie" on the table "Movies". I know how to have autoit open the file and enter the correct keys, but i would like to write something like "filewriteline('C:\My Documents\moviename.txt',1)" only for a Database. Any Ideas? Examples? Link to comment Share on other sites More sharing options...
DjDeep00 Posted February 11, 2008 Share Posted February 11, 2008 I want to be able to add a movie title to the column titled "originalMovie" on the table "Movies".In order todo this you will need to connect to the access database and use a insert sql to add a movie title.I know how to have autoit open the file and enter the correct keys, but i would like to write something like "filewriteline('C:\My Documents\moviename.txt',1)" only for a Database.I have no clue what you mean by this? First you are talking about writing to a database and here you are talking about some text file. Link to comment Share on other sites More sharing options...
Avman9000 Posted February 11, 2008 Author Share Posted February 11, 2008 "In order todo this you will need to connect to the access database and use a insert sql to add a movie title." Do you have an example of what this would look like? "I have no clue what you mean by this? First you are talking about writing to a database and here you are talking about some text file." This was an example. I would like to know what code i would need for filling in the 'xxxxx' in.... 'FileWriteLine' is to '.txt' as 'xxxxx' is to ".mdb" hope that clarifies Link to comment Share on other sites More sharing options...
ResNullius Posted February 11, 2008 Share Posted February 11, 2008 "In order todo this you will need to connect to the access database and use a insert sql to add a movie title."Do you have an example of what this would look like?"I have no clue what you mean by this? First you are talking about writing to a database and here you are talking about some text file."This was an example. I would like to know what code i would need for filling in the 'xxxxx' in.... 'FileWriteLine' is to '.txt' as 'xxxxx' is to ".mdb"hope that clarifiesGEOSoft has a set of functions worked up for deaing with Access databases in his Access UDF here: http://www.autoitscript.com/forum/index.php?showtopic=40397 Link to comment Share on other sites More sharing options...
Avman9000 Posted February 12, 2008 Author Share Posted February 12, 2008 ;what am i doing wrong? this does not alter my database in any way. $adSource = "K:\My Movies\TempMyMovies.mdb" ;this is the name and location of my database $adTable = "movies" ;this is the table name $rData = "testMovieName" ;this is the text to be added $adCol = "Name" ;this is the column name #include-once Global Const $adoProvider = 'Microsoft.Jet.OLEDB.4.0; ' Global Const $adOpenDynamic = 2 Global Const $adOpenStatic = 3 Global Const $adLockReadOnly =1 Global Const $adLockPessimistic = 2 Global Const $adLockOptimistic = 3 Global Const $adLockBatchOptimistic = 4 Global Const $adPersistXML = 1 Global Const $adUseClient = 3 Global Const $adSchemaTables = 20 Global Const $adVarChar = 200 Global Const $MaxCharacters = 255 ;Private Functions Func _accessOpen($adSource) $oADO = ObjCreate("ADODB.Connection") $oADO.Provider = $adoProvider $oADO.Open ($adSource) Return $oADO EndFunc ;<===> _accessOpen() Func _accessOpenRecordset() $oRec = ObjCreate("ADODB.Recordset") Return $oRec EndFunc ;<===> _accessOpenRecordset() ;=============================================================================== ; Function Name: _accessAddRecord() ; Description: Add a new record (single or multiple fields) in an existing MS Access database table ; Syntax: _accessAddRecord($adSource, $adTable) ; Parameter(s): $adSource - The full path/filename of the database to be opened ; $adTable - the name of the table to add the record to ; $rData - Data to be added to field (to add data to multiple fields this must be an array) see notes ; $adCol - the name or 0 based index of the field to add the data to when $rData is not an array (default is first field) ; Requirement(s): ; Return Value(s): Success - @Error = 0 and record is added to table ; Failure - Sets @Error ; 1 = unable to create connection ; 2 = unable to create recordset ; Author(s): GEOSoft ; Note(s): ; Modification(s): ;=============================================================================== Func _accessAddRecord($adSource, $adTable, $rData,$adCol = 0) If NOT IsArray($rData) Then $rData = StringSplit($rData,'|') EndIf $oADO = 'ADODB.Connection' If IsObj($oADO) Then $oADO = ObjGet('',$oADO) Else $oADO = _accessOpen($adSource) EndIf If IsObj($oADO) = 0 Then Return SetError(1) If Not IsObj($oADO) Then Return SetError(2, 0, 0) $oRec = _accessOpenRecordset();ObjCreate("ADODB.Recordset") If IsObj($oRec) = 0 Then Return SetError(2) With $oRec .Open ("SELECT * FROM " & $adTable , $oADO, $adOpenStatic, $adLockOptimistic) .AddNew If IsArray($rData) Then For $I = 1 To Ubound($rData) -1;$rData[0] $rData[$I] = StringStripWs($rData[$I],1) .Fields.Item($I -1) = $rData[$I] Next Else .Fields.Item($adCol) = $rData EndIf .Update .Close EndWith $oADO.Close() EndFunc ;<===> _accessAddRecord() Link to comment Share on other sites More sharing options...
DjDeep00 Posted February 12, 2008 Share Posted February 12, 2008 @Avman9000...These are just the functions...you need to call these functions with parameters...Take a look at some examples in the post provided above... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now