Sign in to follow this  
Followers 0
dorit30

DATABASE OBJECT, COPY a Field in an mdb database to another mdb database

5 posts in this topic

hi guyz i got data1.mdb and i want to copy to data2.mdb only 1 field and the all recordS

(copy Table to Table i already know, and also add 1 record to the field )

this where i stuck (AND ITS TOOK FROM AccessExample.au3 0_28) :

CODE
Func _ReadOneField($q_sql, $s_dbname, $s_field, ByRef $o_adoCon, $i_adoMDB = 1, $USRName = "", $PWD = "")

Local $_output

If Not IsObj($o_adoCon) Then

_AccessConnectConn($s_dbname, $o_adoCon, $i_adoMDB, $USRName, $PWD)

$i_NeedToCloseInFunc = 1

Else

$i_NeedToCloseInFunc = 0

EndIf

$o_adoRs = ObjCreate("ADODB.Recordset")

$o_adoRs.CursorType = 1

$o_adoRs.LockType = 3

$o_adoRs.Open ($q_sql, $o_adoCon)

With $o_adoRs

If .RecordCount Then

While Not .EOF

$_output = $_output & .Fields ($s_field).Value & @CRLF

.MoveNext

WEnd

EndIf

EndWith

$o_adoRs.Close

If $i_NeedToCloseInFunc Then $o_adoCon.Close

Return $_output

EndFunc ;==>_ReadOneField

Func _AddData($s_dbname, $s_Tablename, $s_Fieldname, $s_i_value, ByRef $o_adoCon, $i_adoMDB = 1, $USRName = "", $PWD = "")

If Not IsObj($o_adoCon) Then

_AccessConnectConn($s_dbname, $o_adoCon, $i_adoMDB, $USRName, $PWD)

$i_NeedToCloseInFunc = 1

Else

$i_NeedToCloseInFunc = 0

EndIf

$o_adoRs = ObjCreate("ADODB.Recordset")

$o_adoRs.CursorType = 1

$o_adoRs.LockType = 3

$o_adoRs.Open ("SELECT * FROM " & $s_Tablename, $o_adoCon)

;~ MsgBox(0, "_AddData", "$o_adoRs.Recordcount=" & $o_adoRs.RecordCount+1)

$o_adoRs.AddNew

;~ $o_adoRs.Fields ("ROWID").Value = $o_adoRs.RecordCount+1

$o_adoRs.Fields ($s_Fieldname).Value = $s_i_value

$o_adoRs.Update

$o_adoRs.Close

If $i_NeedToCloseInFunc Then $o_adoCon.Close

EndFunc ;==>_AddData

Local $o_Con,$o_Con2,$o_Rs

$s_Tablename = "DATA_COUNTER"

$s_dbname = "c:\1\tt.mdb"

$Fieldname0 = "IN"

$dbname = "c:\1\itay.mdb"

$tblname = "סניף_1"

$fldname = "כניסות"

Func _AccessConnectConn($s_dbname, ByRef $o_adoCon, $i_adoMDB = 1, $USRName = "", $PWD = "")

;MsgBox(0, "$USRName/$PWD", $USRName&@lf&$PWD)

$o_adoCon = ObjCreate("ADODB.Connection")

If Not $i_adoMDB Then $o_adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $s_dbname & ";User Id=" & $USRName & ";Password=" & $PWD & ";")

If $i_adoMDB Then $o_adoCon.Open ("Driver={Microsoft Access Driver (*.mdb)};Dbq=" & $s_dbname & ';UID=' & $USRName & ';PWD=' & $PWD)

Return $o_adoCon

EndFunc ;==>_AccessConnectConn

_AccessConnectConn($s_dbname, $o_Con,0)

$query = "SELECT * FROM " & $s_Tablename

$strData = _ReadOneField ($query, $s_dbname, $Fieldname0, $o_Con)

MsgBox(0, "Entire field", $strData)

_AccessConnectConn($dbname, $o_Con,0)

_AddData ($dbname, $tblname, $fldname, $strData, $o_Con)

only 1 data add to the new mdb field and the first 1, Why not all the $strData is enter

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ANY1 ??

Edited by dorit30

Share this post


Link to post
Share on other sites

up

Share this post


Link to post
Share on other sites

Hi,

still no time..

method, I think;'

1. Get output from fields in 1 db

2. Stringsplit to array

3. close that db, open 2nd db.

4. check field exists in 2nd db

5. else add field

6. loop through array and insetr data in the field for each row.

Best, randall ; let me know...

Share this post


Link to post
Share on other sites

Hi,

still no time..

method, I think;'

1. Get output from fields in 1 db

2. Stringsplit to array

3. close that db, open 2nd db.

4. check field exists in 2nd db

5. else add field

6. loop through array and insetr data in the field for each row.

Best, randall ; let me know...

Dear Randallc I know this but when i insert (and i got more then 1 Field) its from left to right and i need only the left to fill (If i got 2 Rows)

I try to use the _AddRecord UDF and use "|" but still left to right

SO How I Can Fill Only 1 Row or What to use after | to left the right row blank

10nx a lot

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0