Author |
Topic |
sr_aneesh
Starting Member
17 Posts |
Posted - 2005-01-16 : 12:04:30
|
i have a dbf file with some data. I want to import the data from the dbf file to SQL.Currently what I do is(Code shown below) i select records from the dbf file and import records one by one after checking if the records already exist. this works fine But i doubt this is a little slow process. How do i do this using stored procedure. '-------------------Database connection for DBF File Starts--------Set DBConn = OpenDBFConn(filepath)'-------------------Database connection for DBF File Ends--------sqlstr="Select * from ["&filenam&"]"Set rs = DBConn.Execute(sqlstr)'-------------------Database connection for Access File Starts--------SET DB=SERVER.CREATEOBJECT("ADODB.CONNECTION") DB.OPEN "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & SERVER.MAPPATH("table.mdb")'-------------------Database connection for Access File Ends--------while not rs.eof sqlchk="select drno from tblmain where blno ='"&rs(0)&"' and containerno='"&rs(3)&"'" '-----Check if Records Already Exist set rschk=db.Execute(sqlchk) if rschk.eof then sqlin="insert into tblmain(no,fld1,fld2,fld3,fld4,fld5,fld6,fld7,fld8,fld9,fld10,fld4,fld54,fld15) values('"&rs(0)&"','"&rs(1)&"','"&rs(2)&"','"&rs(3)&"','"&rs(4)&"','"&rs(5)&"','"&rs(6)&"','"&rs(7)&"','"&rs(8)&"','"&rs(9)&"','"&rs(10)&"','"&rs(11)&"','"&rs(12)&"','"&rs(13)&"','"&rs(14)&"')" db.Execute (sqlin) end if %><%rs.movenextwendThanx in Advance. |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-01-18 : 01:16:29
|
Create a stored Procedure having thisinsert into tblmain(no,fld1,fld2,fld3,fld4,fld5,fld6,fld7,fld8,fld9,fld10,fld4,fld54,fld15) values(no,valu1,value2,...value15) where drno not in(Select drno from FileName) call this in your ASP CodeMadhivanan |
|
|
|
|
|