Archive for October, 2008

isIdentity sql query

select COLUMNPROPERTY(object_id(‘tmp’),’id1′,’isIdentity’)
sp_configure ‘allow update’, 1
go
reconfigure with override
go
update syscolumns set colstat = colstat – 1
where id = object_id(‘tmp’)
and name = ‘id1’
go
exec sp_configure ‘allow update’, 0
go
reconfigure with override
go

Advertisements

October 18, 2008 at 10:02 am Leave a comment

Function c# run sql destination

public void runsqldestination(string query)
{

string sqlupd = query;

SqlCommand cmd6 = new SqlCommand(sqlupd, MSSqlcon2);
cmd6.CommandTimeout = 99920;

try
{
cmd6.ExecuteNonQuery();

}

catch
{ MessageBox.Show(” Error ! “); }
}

October 18, 2008 at 9:59 am Leave a comment

Convert dataset to sql query insert

public void GetDataset(DataSet ds, string TableName)
{
string squeryInsert = “insert into ” + TableName + ” (“;

for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
{
if (i == 0)
{
squeryInsert = squeryInsert + ds.Tables[0].Columns[i].ToString();
}
else
{
squeryInsert = squeryInsert + “,” + ds.Tables[0].Columns[i].ToString();
}

}
squeryInsert = squeryInsert + “) values ( “;

DataRow[] row1 = ds.Tables[0].Select();

string squery = “”;
for (int ii = 0; ii < row1.Length; ii++)//pernoume ta rows
{
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)// pernoume ta column
{
if (i == 0)
{
squery = squery + “N'” + row1[ii][i].ToString().Replace(“‘”, “””).Replace(@”\”, @”\\”) + “‘”;
}
else
{
squery = squery + “,N” + “‘” + row1[ii][i].ToString().Replace(“‘”, “””).Replace(@”\”, @”\\”) + “‘”;
}

}
squery = squeryInsert + squery + ” )”;

RunSql(squery);
runsqldestination(squery);

lblProgressBar.Text = “Progess  ” + TableName.ToUpper() + ” :”;
progressBar1.Maximum = row1.Length;
progressBar1.Minimum = 0;
progressBar1.Value = ii;
Application.DoEvents();

squery = “”;

}

}

October 18, 2008 at 9:58 am Leave a comment

Newer Posts


October 2008
M T W T F S S
« Sep   Feb »
 12345
6789101112
13141516171819
20212223242526
2728293031