Posted on July 10, 2008 by Siemen
Here I will show how to Import data from csv file to sql database or any other database.
//This is the connection string to connect to your csv file
string strConString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\; Extended Properties=\”Text;HDR=YES;\””;
// open connection
OleDbConnection oCon = new OleDbConnection(strConString);
oCon.Open();
// fill data set
string strSql = “SELECT * FROM csvfile.csv”; //csvfile should be present in c:
OleDbDataAdapter [...]
Filed under: asp.net c#, csv, sql | Tagged: c#, csv, csv to sql, dot net, get csv, import csv file to database, import csv to sql, read csv file, sql | 6 Comments »
Posted on June 2, 2008 by Siemen
Create a function in MSSQL to remove all special characters from XML.
ALTER FUNCTION [dbo].[RemoveSpChar]
(
– Add the parameters for the function here
@sInput varchar(MAX)=”
)
RETURNS varchar(MAX)
AS
BEGIN
– Declare the return variable here
DECLARE @sOutput Varchar(MAX),
@iIndex int,
@iLength int,
@sChar varchar(1),
@iASCII int,
@iLen int,
@iRem int
set @sInput= ltrim(rtrim(@sInput))
set @iLength = len(@sInput)
set @iIndex =1
set @sOutput=”
while @iIndex <= @iLength
begin
set @sChar=substring(@sInput,@iIndex,1)
set @iASCII=ascii(@sChar)
if ((@iASCII>=48 and @iASCII<=57) or (@iASCII>=65 [...]
Filed under: sql, xml | Tagged: mssql function, remove special character from xml string, sql, sql function to remove special character, xml, xml special character, xml string | Leave a Comment »
Posted on April 30, 2008 by Siemen
Subscribe to RSS headline updates from: Powered by FeedBurner
Filed under: 1 | Tagged: Asp.Net, c#, sql, xml | Leave a Comment »