lnLastRow = loExcel.activesheet.UsedRange.ROWS.COUNT
lnLastCol = loExcel.activesheet.UsedRange.COLUMNS.COUNT
Tuesday, July 27, 2010
Monday, July 26, 2010
Excel Fit to page using Foxpro Automation
loExcel.ActiveSheet.PageSetup.Zoom = .f.
loExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
loExcel.ActiveSheet.PageSetup.FitToPagesTall = 1
loExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
loExcel.ActiveSheet.PageSetup.FitToPagesTall = 1
Wednesday, July 29, 2009
Resize dbf column length to maximum content length
lnSelect = SELECT()
lcAlias = ALIAS()
USE DBF() EXCLUSIVE
lnFields = AFIELDS(aa)
FOR i = 1 TO lnFields
lcField = aa[i, 1]
lcType = aa[i,2]
lnOrigLen = aa[i, 3]
IF lcType = 'C'
SELECT MAX(LEN(ALLTRIM(&lcField))) maxlen FROM (lcAlias) INTO ARRAY curlen
lnLen = IIF(curlen = 0, 1, curlen)
IF lnOriglen > lnLen
ALTER table (lcAlias) alter COLUMN (lcField) c(lnLen)
?lcField, curlen
ENDIF
ENDIF
ENDFOR
SELECT (lnSelect)
RETURN
lcAlias = ALIAS()
USE DBF() EXCLUSIVE
lnFields = AFIELDS(aa)
FOR i = 1 TO lnFields
lcField = aa[i, 1]
lcType = aa[i,2]
lnOrigLen = aa[i, 3]
IF lcType = 'C'
SELECT MAX(LEN(ALLTRIM(&lcField))) maxlen FROM (lcAlias) INTO ARRAY curlen
lnLen = IIF(curlen = 0, 1, curlen)
IF lnOriglen > lnLen
ALTER table (lcAlias) alter COLUMN (lcField) c(lnLen)
?lcField, curlen
ENDIF
ENDIF
ENDFOR
SELECT (lnSelect)
RETURN
Labels:
Foxpro
Tuesday, April 14, 2009
Grant Execute Role
Granting execute permissions to all stored procedures in a database
CREATE ROLE db_executor
GRANT EXECUTE TO db_executor
from article on SqlDbaTips.com
CREATE ROLE db_executor
GRANT EXECUTE TO db_executor
from article on SqlDbaTips.com
Labels:
Sql Server
Sunday, February 22, 2009
Add jquery to any page
Here's how we can add jQuery to the pages you are viewing
var Head = document.getElementsByTagName('head').item(0);
script = document.createElement("script");
url="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js";
script.src = url;
Head.appendChild(script);
var Head = document.getElementsByTagName('head').item(0);
script = document.createElement("script");
url="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js";
script.src = url;
Head.appendChild(script);
Sunday, January 4, 2009
Linq with text file
DataTable dt = new DataTable();
using (OleDbDataAdapter da = new OleDbDataAdapter(
@"SELECT * FROM F:\myvfp\books.csv",
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\;
Extended Properties=""Text;HDR=No;FMT=Delimited"""))
{
da.Fill(dt);
}
var books = from b in dt.AsEnumerable()
select new
{
Title = b.Field<string>(0),
Publisher = b.Field<string>(1),
Year = b.Field<int>(2)
};
foreach (var book in books)
{
Console.WriteLine(string.Format("Title: {0}, Publisher: {1}, Year: {2}", book.Title, book.Publisher, book.Year));
}
using (OleDbDataAdapter da = new OleDbDataAdapter(
@"SELECT * FROM F:\myvfp\books.csv",
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\;
Extended Properties=""Text;HDR=No;FMT=Delimited"""))
{
da.Fill(dt);
}
var books = from b in dt.AsEnumerable()
select new
{
Title = b.Field<string>(0),
Publisher = b.Field<string>(1),
Year = b.Field<int>(2)
};
foreach (var book in books)
{
Console.WriteLine(string.Format("Title: {0}, Publisher: {1}, Year: {2}", book.Title, book.Publisher, book.Year));
}
Saturday, January 3, 2009
Linq with foxpro table
DataTable dt = new DataTable();
using (OleDbDataAdapter da = new OleDbDataAdapter(@"select title as Title, publisher as Publisher, year as Year from books", @"Provider=VFPOLEDB.1;Data Source=c:\myvfp\"))
{
da.Fill(dt);
}
XElement xml = new XElement("books",
dt.AsEnumerable().Where(book =>
book.Field<int>("Year") == 2006)
.Select(book => new XElement("book",
new XAttribute(
"title",
book.Field<string>("Title")),
new XElement(
"publisher",
book.Field<string>("Publisher"))
))
);
Console.WriteLine(xml);
or
XElement xml = new XElement("books",
from book in dt.AsEnumerable()
where book.Field<int>("Year") == 2006
select new XElement("book",
new XAttribute("title", book.Field<string>("Title")),
new XElement("publisher", book.Field<string>("Publisher")
)));
Console.WriteLine(xml);
Instead of
from book in dt.AsEnumerable()
we can use
from DataRow book in dt.Rows
using (OleDbDataAdapter da = new OleDbDataAdapter(@"select title as Title, publisher as Publisher, year as Year from books", @"Provider=VFPOLEDB.1;Data Source=c:\myvfp\"))
{
da.Fill(dt);
}
XElement xml = new XElement("books",
dt.AsEnumerable().Where(book =>
book.Field<int>("Year") == 2006)
.Select(book => new XElement("book",
new XAttribute(
"title",
book.Field<string>("Title")),
new XElement(
"publisher",
book.Field<string>("Publisher"))
))
);
Console.WriteLine(xml);
or
XElement xml = new XElement("books",
from book in dt.AsEnumerable()
where book.Field<int>("Year") == 2006
select new XElement("book",
new XAttribute("title", book.Field<string>("Title")),
new XElement("publisher", book.Field<string>("Publisher")
)));
Console.WriteLine(xml);
Instead of
from book in dt.AsEnumerable()
we can use
from DataRow book in dt.Rows
Subscribe to:
Posts (Atom)