Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating DBF file.....

Author  Topic 

Dorffius
Starting Member

36 Posts

Posted - 2002-03-01 : 10:02:58
How would I go about creating a brand new dbf file from a recordset? I can't find examples of this anywhere.

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-03-02 : 07:19:34
Check out the DTS tab from Enterprise Manger. You should be able to create a .dbf from a recordset trivially.

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

Dorffius
Starting Member

36 Posts

Posted - 2002-03-04 : 09:08:19
Sorry, I'm unfamiliar with what you are talking about. Enterprise Manager? Where would I find that?

Thanks in advance.

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-03-04 : 11:01:54
Enterprise Manager (aka EM) comes with SQL Server and is it's default administration tool for defining databases, managing backups, managing stored procedures, etc. It's not necessarily the best (or easiest) way to achieve everything with regard to a database, but it is the one supplied with the s/w.


It comes as part of the administration when SQL Server is installed on the server. It also can be installed on a client machine (from which administration activities can be actioned) - I think it's a subset/superset?? of a client-installation.


Books Online (SQL Servers help files) will contain descriptions on this utility.

Go to Top of Page

Dorffius
Starting Member

36 Posts

Posted - 2002-03-04 : 11:09:42
I would love to use that but unfortunately I do not have access to it and the program that is calling these SQL statements is actually part of our intranet, therefore ASP.

Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-03-04 : 17:09:01
If you really are stuck with ASP only, have a look at the following Javascript code...it translates an HTML table into an MS Excel spreadhseet using the HTML DOM. (ie CLIENT SIDE - Yippee!!)

Once you have it as an excel spreadsheet, you should be able to save it as a .dbf - automatically, or as the user requires. notice the oXL.Visible = True - if you don't want the user to see it - then don't do this bit....

Problems are as follows- Users will have to turn their security settings off in IE - otherwise the script will not be able to launch the Excel Object. In IE - this can be done for intranet only - and b'sides, they can turn it straight back on again (once I've taken control of their harddrives) - oops I mean, once they've finished.

	function fnAutomateExcel(){
var oXL = new ActiveXObject("Excel.Application")
oXL.Visible = false

var oWB = oXL.Workbooks.Add()
var oSheet = oWB.ActiveSheet

mybody=document.getElementsByTagName("body").item(0)
mytable=mybody.getElementsByTagName("table").item(0)
mytablebody=mytable.getElementsByTagName("tbody").item(0)

for(var i = 0;i<mytablebody.getElementsByTagName("tr").length;i++){
myrow=mytablebody.getElementsByTagName("tr").item(i)
if(i == 0){
for(var x = 1;x<myrow.getElementsByTagName("th").length;x++){
mycel=myrow.getElementsByTagName("th").item(x)
oSheet.Cells(i+1, x).Value = mycel.childNodes.item(0).data
oSheet.Cells(i+1, x).Font.Bold = true
}
} else {
if(myrow.getElementsByTagName("td").length != 0){
for(var x = 1;x<myrow.getElementsByTagName("td").length;x++){
try{
mycel=myrow.getElementsByTagName("td").item(x)
oSheet.Cells(i+1, x).Value = mycel.getElementsByTagName("input").item(0).value
}
catch(error){
mycel=myrow.getElementsByTagName("td").item(x)
oSheet.Cells(i+1, x).Value = mycel.childNodes.item(0).data
}
}
} else {
for(var x = 1;x<myrow.getElementsByTagName("th").length;x++){
mycel=myrow.getElementsByTagName("th").item(x)
oSheet.Cells(i+1, x).Value = mycel.childNodes.item(0).data
oSheet.Cells(i+1, x).Font.Bold = true
}
}
}

}

oSheet.Range(oSheet.Cells(1,1),oSheet.Cells(i,x)).EntireColumn.AutoFit

oXL.Visible = true
oXL.UserControl = true
}


Edited by - rrb on 03/04/2002 17:13:08
Go to Top of Page

Dorffius
Starting Member

36 Posts

Posted - 2002-03-05 : 08:35:45
Thanks a lot for the code. I'll try it out and let you know the results.

Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-03-05 : 17:06:21
quote:

Thanks a lot for the code. I'll try it out and let you know the results.



Pleasure - and if you're not "up" on the HTML-DOM please feel free to ask.

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -