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
Wednesday, July 29, 2009
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
Wednesday, August 13, 2008
Foxpro Word Automation Replace
The word Macro generates following code to do search and "REPLACE"
With Selection.Find
.Text = "findword"
.Replacement.Text = "replaceword"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
The above will not work in Foxpro, Foxpro use positional parameters
Function Execute([FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]) As Boolean
To use in Foxpro, we have to provide all paramters in right sequence till "ReplaceWith". We can omit rest of the parameters
Const wdFindContinue = 1
oword.Selection.Find.Execute(tcOriginal, .f., .f., .f., .f., .f., .t., wdFindContinue, .f., tcReplace)
With Selection.Find
.Text = "findword"
.Replacement.Text = "replaceword"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
The above will not work in Foxpro, Foxpro use positional parameters
Function Execute([FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]) As Boolean
To use in Foxpro, we have to provide all paramters in right sequence till "ReplaceWith". We can omit rest of the parameters
Const wdFindContinue = 1
oword.Selection.Find.Execute(tcOriginal, .f., .f., .f., .f., .f., .t., wdFindContinue, .f., tcReplace)
Labels:
Foxpro,
Word Automation
Wednesday, August 6, 2008
SYS(987) Foxpro
Foxpro SYS(987) can be used to return remote Varchar data as ANSI for use with Memo fields.
Remote data with varchar fields in foxpro displays square box between each characters

By setting SYS(987, .T.) the data will be in ANSI format.
The above data now displayed as
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Remote data with varchar fields in foxpro displays square box between each characters

By setting SYS(987, .T.) the data will be in ANSI format.
The above data now displayed as
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Labels:
Foxpro
Subscribe to:
Posts (Atom)