How to access Cmd.exe in Windows 7?
Posted: January 31, 2010 Filed under: My IT tools Leave a commentTo get to the command prompt, run Cmd.exe, which you can do in any of the following ways:
-
Type cmd in the Start menu search box, and click the Cmd shortcut when it appears, under Programs, at the top of the menu.
-
Press Windows logo key+R, and type cmd in the Open box.
-
Choose Start, All Programs, Accessories, Command Prompt.
-
Double-click the Cmd icon in your %SystemRoot%\System32 folder.
-
Double-click any shortcut for Cmd.exe.
Problem with Using SQL Server Express user instancing under IIS
Posted: January 31, 2010 Filed under: SQL Server 2005 Express Leave a commentBulkcopy Excel 2007 data to SQL Server: Issue— Could not find installable ISAM
Posted: January 31, 2010 Filed under: Excel 2007 1 Comment{
string OLEDBConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|ImportUserFile.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES"""; // string OLEDBConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\datatest\ImportUserFile.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES"""; using (System.Data.OleDb.OleDbConnection myConnection = new System.Data.OleDb.OleDbConnection(OLEDBConnectionString)){
OleDbCommand command = new OleDbCommand("SELECT UserID, Password, FirstName, LastName, Email, Address, PostalCode, MobilePhone, HomeNumber, DD, MM, YYYY, Role FROM [ImportUserFile$]", myConnection);myConnection.Open();
using (System.Data.OleDb.OleDbDataReader dr = command.ExecuteReader()){
string sqlConnectionString = ConfigurationManager.ConnectionStrings["test_for_forumConnectionString"].ToString(); // Bulk Copy to SQL Server using (System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(sqlConnectionString)){
bulkCopy.DestinationTableName =
"dbo.Account"; //Define ColumnMappings: source(Excel) –destination(DB Table column)bulkCopy.ColumnMappings.Add(
"UserID", "UserID");bulkCopy.ColumnMappings.Add(
"Password", "Password");bulkCopy.ColumnMappings.Add(
"FirstName", "FirstName");bulkCopy.ColumnMappings.Add(
"LastName", "LastName");bulkCopy.ColumnMappings.Add(
"Email", "Email");bulkCopy.ColumnMappings.Add(
"Address", "Address");bulkCopy.ColumnMappings.Add(
"PostalCode", "PostalCode");bulkCopy.ColumnMappings.Add(
"MobilePhone", "MobilePhone");bulkCopy.ColumnMappings.Add(
"HomeNumber", "HomeNumber");bulkCopy.ColumnMappings.Add(
"DD", "DD");bulkCopy.ColumnMappings.Add(
"MM", "MM");bulkCopy.ColumnMappings.Add(
"YYYY", "YYYY");bulkCopy.ColumnMappings.Add(
"Role", "Role");bulkCopy.WriteToServer(dr);
}
}
}
}
Use a Pipe delemited file in ASP.NET
Posted: January 30, 2010 Filed under: ASP.NET 2 Leave a commentOne way to define the delimiter: you can use a Schema.ini file to define your text file name and delimiter.
Here is a sample Schema.ini file and it will sit in the same folder as your text file.:
[myPipeFileName.txt]
Format=Delimited(|)
ColNameHeader=False
MaxScanRows=0
More information about Schema.ini: http://msdn.microsoft.com/en-us/library/ms709353(VS.85).aspx
{
string str = System.IO.Path.GetDirectoryName(MapPath(".\\App_Data\\myPipe.txt")); string strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + str + "; Extended Properties=\"Text;HDR=No;\""; OleDbConnection oCon = new OleDbConnection(strConString);oCon.Open();
//F1, F2, F3 …. in the place of column names string strSql = "SELECT * FROM myPipe.txt"; OleDbDataAdapter daSource = new OleDbDataAdapter(strSql, oCon); DataSet ds = new DataSet();daSource.AcceptChangesDuringFill =
false;daSource.Fill(ds,
"TransferData");GridView3.DataSource = ds;
GridView3.DataBind();
}
How to deploy a SQL Server report with VS 2008 in Windows 7?
Posted: January 25, 2010 Filed under: SQL Server 2008 Leave a commentWhere is the Design View in VS 2010?
Posted: January 24, 2010 Filed under: ASP.NET 4 Leave a commentDelete records in a tree structure with SQL
Posted: January 12, 2010 Filed under: SQL Server 2005 Leave a comment(LocationID int, Title varchar(50), description varchar(50), ParentLocationID int)
insert into Locations values (1,’aaa1′,’about aaa1′, null)
insert into Locations values (2,’aaa2′,’about aaa2′, 23)
insert into Locations values (3,’aaa3′,’about aaa3′, 24)
insert into Locations values (4,’aaa4′,’about aaa4′, 23)
insert into Locations values (5,’aaa5′,’about aaa5′, 24)
insert into Locations values (13,’aaa13′,’about aaa13′, 12)
insert into Locations values (14,’aaa14′,’about aaa41′, 12)
insert into Locations values (15,’aaa15′,’about aaa15′, 12)
insert into Locations values (113,’aaa113′,’about aaa113′, 15)
insert into Locations values (114,’aaa114′,’about aaa114′, 113)
insert into Locations values (115,’aaa115′,’about aaa115′, 114)
insert into Locations values (23,’aaa23′,’about aaa23′, 1)
insert into Locations values (24,’aaa24′,’about aaa24′, 1)
insert into Locations values (25,’aaa5′,’about aaa25′, 23)
set @LocationID =12
AS
(
— Anchor member definition
SELECT e.LocationID, e.ParentLocationID, e.Title, e.description , 0 AS Level
WHERE e.LocationID=@LocationID
UNION ALL
— Recursive member definition
SELECT e.LocationID, e.ParentLocationID, e.Title, e.description, Level + 1
ON e.ParentLocationID= d.LocationID
)
— Statement that executes the CTE
—-SELECT LocationID, Title, description, ParentLocationID, Level
—-FROM DirectReports
—-order by Level,LocationID
DELETE Locations
FROM Locations L INNER JOIN DirectReports D ON L.LocationID=D.LocationID
jQuery Samples from Scott Mitchell at 4Guysfromrolla
Posted: January 11, 2010 Filed under: My IT tools Leave a commentAdd line break in Javascript from HTML page
Posted: January 11, 2010 Filed under: jQuery/Javascript Leave a commentalert(document.getElementById(
"teksts").innerHTML.toString().replace(‘\\n’, "\n"));}
</
script>…
<
input type="button" value="Show First DIV Content" onclick="fnGetLineBreak()" ><a
id="teksts">line 8\nline 9</a> <a id="teksts">line 8\nline 9</a>