Hi nedash,
Refer below code.
Namespaces
C#
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
VB.Net
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text
Code
C#
string primaryKey, tableName = "Estate_TR";
string updateAdd = "";
protected void OnDownload(object sender, EventArgs e)
{
DownloadScript();
}
public string GenerateCreateTableScript()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"DECLARE @object_name SYSNAME
, @object_id INT
, @SQL NVARCHAR(MAX)
SELECT
@object_name = '[' + OBJECT_SCHEMA_NAME(o.[object_id]) + '].[' + OBJECT_NAME([object_id]) + ']'
, @object_id = [object_id]
FROM (SELECT [object_id] = OBJECT_ID('dbo.Estate_TR', 'U')) o
SELECT @SQL = 'DROP TABLE Estate_TR
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF((
SELECT CHAR(13) + ' , [' + c.name + '] ' +
CASE WHEN c.is_computed = 1
THEN 'AS ' + OBJECT_DEFINITION(c.[object_id], c.column_id)
ELSE
CASE WHEN c.system_type_id != c.user_type_id
THEN '[' + SCHEMA_NAME(tp.[schema_id]) + '].[' + tp.name + ']'
ELSE '[' + UPPER(tp.name) + ']'
END +
CASE
WHEN tp.name IN ('varchar', 'char', 'varbinary', 'binary')
THEN '(' + CASE WHEN c.max_length = -1
THEN 'MAX'
ELSE CAST(c.max_length AS VARCHAR(5))
END + ')'
WHEN tp.name IN ('nvarchar', 'nchar')
THEN '(' + CASE WHEN c.max_length = -1
THEN 'MAX'
ELSE CAST(c.max_length / 2 AS VARCHAR(5))
END + ')'
WHEN tp.name IN ('datetime2', 'time2', 'datetimeoffset')
THEN '(' + CAST(c.scale AS VARCHAR(5)) + ')'
WHEN tp.name = 'decimal'
THEN '(' + CAST(c.[precision] AS VARCHAR(5)) + ',' + CAST(c.scale AS VARCHAR(5)) + ')'
ELSE ''
END +
CASE WHEN c.collation_name IS NOT NULL AND c.system_type_id = c.user_type_id
THEN ' COLLATE ' + c.collation_name
ELSE ''
END +
CASE WHEN c.is_nullable = 1
THEN ' NULL'
ELSE ' NOT NULL'
END +
CASE WHEN c.default_object_id != 0
THEN ' CONSTRAINT [' + OBJECT_NAME(c.default_object_id) + ']' +
' DEFAULT ' + OBJECT_DEFINITION(c.default_object_id)
ELSE ''
END +
CASE WHEN cc.[object_id] IS NOT NULL
THEN ' CONSTRAINT [' + cc.name + '] CHECK ' + cc.[definition]
ELSE ''
END +
CASE WHEN c.is_identity = 1
THEN ' IDENTITY(' + CAST(IDENTITYPROPERTY(c.[object_id], 'SeedValue') AS VARCHAR(5)) + ',' +
CAST(IDENTITYPROPERTY(c.[object_id], 'IncrementValue') AS VARCHAR(5)) + ')'
ELSE ''
END
END
FROM sys.columns c WITH(NOLOCK)
JOIN sys.types tp WITH(NOLOCK) ON c.user_type_id = tp.user_type_id
LEFT JOIN sys.check_constraints cc WITH(NOLOCK)
ON c.[object_id] = cc.parent_object_id
AND cc.parent_column_id = c.column_id
WHERE c.[object_id] = @object_id
ORDER BY c.column_id
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 7, ' ') +
ISNULL((SELECT '
, CONSTRAINT [' + i.name + '] PRIMARY KEY ' +
CASE WHEN i.index_id = 1
THEN 'CLUSTERED'
ELSE 'NONCLUSTERED'
END +' (' + (
SELECT STUFF(CAST((
SELECT ', [' + COL_NAME(ic.[object_id], ic.column_id) + ']' +
CASE WHEN ic.is_descending_key = 1
THEN ' DESC'
ELSE ''
END
FROM sys.index_columns ic WITH(NOLOCK)
WHERE i.[object_id] = ic.[object_id]
AND i.index_id = ic.index_id
FOR XML PATH(N''), TYPE) AS NVARCHAR(MAX)), 1, 2, '')) + ')'
FROM sys.indexes i WITH(NOLOCK)
WHERE i.[object_id] = @object_id
AND i.is_primary_key = 1), '') + CHAR(13) + ');'
SELECT @SQL ";
cmd.Connection = con;
con.Open();
string query = Convert.ToString(cmd.ExecuteScalar());
con.Close();
return query;
}
public void DownloadScript()
{
string iDValues = "", insertQry, updateQry;
int i = 0;
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("select * from Estate_TR", con);
primaryKey = GetPrimaryKey(tableName, conString);
insertQry = "";
con.Open();
if (File.Exists(Server.MapPath("~/" + tableName + ".sql")))
{
File.Delete(Server.MapPath("~/" + tableName + ".sql"));
}
// Writing Create Table Script.
StreamWriter sw = new StreamWriter(Server.MapPath("~/" + tableName + ".sql"), true, Encoding.UTF8);
sw.Write(GenerateCreateTableScript() + Environment.NewLine);
sw.Close();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
i = i + 1;
updateAdd = "";
insertQry = "";
string celldata = "", coulmenName = "";
for (int j = 0; j < sdr.FieldCount; j++)
{
if (j > 0)
{
coulmenName += "," + sdr.GetName(j).ToString();
celldata += ",'" + sdr[j].ToString() + "'";
}
else
{
coulmenName += sdr.GetName(j).ToString();
celldata += "'" + sdr[j].ToString() + "'";
}
if (primaryKey == sdr.GetName(j).ToString())
{
iDValues = sdr[j].ToString();
}
if (iDValues != null)
{
updateQry = UpdateQuery(coulmenName, celldata, primaryKey, iDValues);
updateAdd += updateQry;
insertQry = InsertQuery(coulmenName, celldata, tableName);
}
}
WriteScripts(tableName, insertQry, updateAdd, iDValues, primaryKey, i);
}
// Download the sql script file.
if (File.Exists(Server.MapPath("~/" + tableName + ".sql")))
{
byte[] bytes = File.ReadAllBytes(Server.MapPath("~/" + tableName + ".sql"));
File.Delete(Server.MapPath("~/" + tableName + ".sql"));
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + tableName + ".sql");
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
}
public string GetPrimaryKey(string tableName, string cnnString)
{
string iD = "";
SqlConnection con = new SqlConnection(cnnString);
SqlCommand cmd = new SqlCommand("sp_pkeys", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@table_name", SqlDbType.NVarChar).Value = tableName;
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
iD = sdr[3].ToString();
}
con.Close();
return iD;
}
public void WriteScripts(string tableName, string insertqry, string updateQuery, string iDValues, string PrimaryKey, int i)
{
string script = "";
updateQuery = "UPDATE " + tableName + " SET " + updateQuery + " WHERE " + PrimaryKey + " = ' " + iDValues + "'";
int index = updateQuery.LastIndexOf(",");
string updatqry = updateQuery.Remove(index, 1);
if (i == 1)
{
script += "DECLARE @updateCount INT;" + Environment.NewLine;
script += "DECLARE @insertCount INT;" + Environment.NewLine;
script += "DECLARE @count INT;" + Environment.NewLine;
script += " SET @updateCount = 0;" + Environment.NewLine;
script += " SET @insertCount = 0;" + Environment.NewLine;
script += "SELECT @count = COUNT(*) FROM [" + tableName + "] WHERE [" + PrimaryKey + "] = '" + iDValues + "'" + Environment.NewLine;
script += "IF @count = 0" + Environment.NewLine;
script += "BEGIN " + Environment.NewLine;
script += "SET IDENTITY_INSERT " + tableName + " ON" + Environment.NewLine;
script += insertqry + " " + Environment.NewLine;
script += "SET IDENTITY_INSERT " + tableName + " OFF" + Environment.NewLine;
script += " SET @insertCount = @insertCount + 1 " + Environment.NewLine;
script += "END" + Environment.NewLine;
script += "ELSE" + Environment.NewLine;
script += "BEGIN" + Environment.NewLine;
script += updatqry + "" + Environment.NewLine;
script += " SET @updateCount = @updateCount + 1 " + Environment.NewLine;
script += "END" + Environment.NewLine;
StreamWriter sw = new StreamWriter(Server.MapPath("~/" + tableName + ".sql"), true, Encoding.UTF8);
sw.Write(script);
sw.Close();
}
else
{
script += "SELECT @count = COUNT(*) FROM [" + tableName + "] WHERE [" + PrimaryKey + "] = '" + iDValues + "'" + Environment.NewLine;
script += "IF @count = 0" + Environment.NewLine;
script += "BEGIN " + Environment.NewLine;
script += "SET IDENTITY_INSERT " + tableName + " ON" + Environment.NewLine;
script += insertqry + "" + Environment.NewLine;
script += "SET IDENTITY_INSERT " + tableName + " OFF" + Environment.NewLine;
script += "SET @insertCount = @insertCount + 1 " + Environment.NewLine;
script += "END" + Environment.NewLine;
script += "ELSE" + Environment.NewLine;
script += "BEGIN " + Environment.NewLine;
script += updatqry + "" + Environment.NewLine;
script += "SET @updateCount = @updateCount + 1 " + Environment.NewLine;
script += "END" + Environment.NewLine;
StreamWriter sw = new StreamWriter(Server.MapPath("~/" + tableName + ".sql"), true, Encoding.UTF8);
sw.Write(script);
sw.Close();
}
}
public string InsertQuery(string columnName, string cellData, string tableName)
{
return "INSERT INTO " + tableName + " (" + columnName + ") VALUES (" + cellData + ")";
}
public string UpdateQuery(string columnName, string cellData, string Names, string value)
{
string iDName, iDValue, ud = "", name = "", values = "";
iDName = Names;
iDValue = value;
if (iDName != null)
{
int indexcolumn = columnName.LastIndexOf(",");
int indexValues = cellData.LastIndexOf(",");
if (indexcolumn > 0 && indexValues > 0)
{
columnName = columnName.Substring(indexcolumn);
cellData = cellData.Substring(indexValues);
name = columnName.Replace(",", "");
values = cellData.Replace(",", "");
if (name != iDName && values != iDValue)
{
ud = name + "=" + values + ",";
}
}
else
{
name = columnName;
values = cellData;
if (name != iDName && values != iDValue)
{
ud = name + "=" + values + ",";
}
}
}
return ud;
}
VB.Net
Private primaryKey As String, tableName As String = "Estate_TR"
Private updateAdd As String = ""
Protected Sub OnDownload(ByVal sender As Object, ByVal e As EventArgs)
DownloadScript()
End Sub
Public Function GenerateCreateTableScript() As String
Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
Dim cmd As SqlCommand = New SqlCommand()
cmd.CommandType = CommandType.Text
cmd.CommandText = "DECLARE @object_name SYSNAME " _
+ ", @object_id INT " _
+ ", @SQL NVARCHAR(MAX) " _
+ "SELECT " _
+ " @object_name = '[' + OBJECT_SCHEMA_NAME(o.[object_id]) + '].[' + OBJECT_NAME([object_id]) + ']' " _
+ " , @object_id = [object_id] " _
+ "FROM (SELECT [object_id] = OBJECT_ID('dbo.Estate_TR', 'U')) o " _
+ "" _
+ "SELECT @SQL = 'DROP TABLE Estate_TR" + Environment.NewLine _
+ " SET ANSI_NULLS ON" + Environment.NewLine _
+ " SET QUOTED_IDENTIFIER ON" + Environment.NewLine _
+ " CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF(( " _
+ " SELECT CHAR(13) + ' , [' + c.name + '] ' + " _
+ " CASE WHEN c.is_computed = 1 " _
+ " THEN 'AS ' + OBJECT_DEFINITION(c.[object_id], c.column_id) " _
+ " ELSE " _
+ " CASE WHEN c.system_type_id != c.user_type_id " _
+ " THEN '[' + SCHEMA_NAME(tp.[schema_id]) + '].[' + tp.name + ']' " _
+ " ELSE '[' + UPPER(tp.name) + ']' " _
+ " END + " _
+ " CASE " _
+ " WHEN tp.name IN ('varchar', 'char', 'varbinary', 'binary') " _
+ " THEN '(' + CASE WHEN c.max_length = -1 " _
+ " THEN 'MAX' " _
+ " ELSE CAST(c.max_length AS VARCHAR(5)) " _
+ " END + ')' " _
+ " WHEN tp.name IN ('nvarchar', 'nchar') " _
+ " THEN '(' + CASE WHEN c.max_length = -1 " _
+ " THEN 'MAX' " _
+ " ELSE CAST(c.max_length / 2 AS VARCHAR(5)) " _
+ " END + ')' " _
+ " WHEN tp.name IN ('datetime2', 'time2', 'datetimeoffset') " _
+ " THEN '(' + CAST(c.scale AS VARCHAR(5)) + ')' " _
+ " WHEN tp.name = 'decimal' " _
+ " THEN '(' + CAST(c.[precision] AS VARCHAR(5)) + ',' + CAST(c.scale AS VARCHAR(5)) + ')' " _
+ " ELSE '' " _
+ " END + " _
+ " CASE WHEN c.collation_name IS NOT NULL AND c.system_type_id = c.user_type_id " _
+ " THEN ' COLLATE ' + c.collation_name " _
+ " ELSE '' " _
+ " END + " _
+ " CASE WHEN c.is_nullable = 1 " _
+ " THEN ' NULL' " _
+ " ELSE ' NOT NULL' " _
+ " END + " _
+ " CASE WHEN c.default_object_id != 0 " _
+ " THEN ' CONSTRAINT [' + OBJECT_NAME(c.default_object_id) + ']' + " _
+ " ' DEFAULT ' + OBJECT_DEFINITION(c.default_object_id) " _
+ " ELSE '' " _
+ " END + " _
+ " CASE WHEN cc.[object_id] IS NOT NULL " _
+ " THEN ' CONSTRAINT [' + cc.name + '] CHECK ' + cc.[definition] " _
+ " ELSE '' " _
+ " END + " _
+ " CASE WHEN c.is_identity = 1 " _
+ " THEN ' IDENTITY(' + CAST(IDENTITYPROPERTY(c.[object_id], 'SeedValue') AS VARCHAR(5)) + ',' + " _
+ " CAST(IDENTITYPROPERTY(c.[object_id], 'IncrementValue') AS VARCHAR(5)) + ')' " _
+ " ELSE '' " _
+ " END " _
+ " END " _
+ " FROM sys.columns c WITH(NOLOCK) " _
+ " JOIN sys.types tp WITH(NOLOCK) ON c.user_type_id = tp.user_type_id " _
+ " LEFT JOIN sys.check_constraints cc WITH(NOLOCK) " _
+ " ON c.[object_id] = cc.parent_object_id " _
+ " AND cc.parent_column_id = c.column_id " _
+ " WHERE c.[object_id] = @object_id " _
+ " ORDER BY c.column_id " _
+ " FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 7, ' ') + " _
+ " ISNULL((SELECT ' " _
+ " , CONSTRAINT [' + i.name + '] PRIMARY KEY ' + " _
+ " CASE WHEN i.index_id = 1 " _
+ " THEN 'CLUSTERED' " _
+ " ELSE 'NONCLUSTERED' " _
+ " END +' (' + ( " _
+ " SELECT STUFF(CAST(( " _
+ " SELECT ', [' + COL_NAME(ic.[object_id], ic.column_id) + ']' + " _
+ " CASE WHEN ic.is_descending_key = 1 " _
+ " THEN ' DESC' " _
+ " ELSE '' " _
+ " END " _
+ " FROM sys.index_columns ic WITH(NOLOCK) " _
+ " WHERE i.[object_id] = ic.[object_id] " _
+ " AND i.index_id = ic.index_id " _
+ " FOR XML PATH(N''), TYPE) AS NVARCHAR(MAX)), 1, 2, '')) + ')' " _
+ " FROM sys.indexes i WITH(NOLOCK) " _
+ " WHERE i.[object_id] = @object_id " _
+ " AND i.is_primary_key = 1), '') + CHAR(13) + ');' " _
+ "SELECT @SQL "
cmd.Connection = con
con.Open()
Dim query As String = Convert.ToString(cmd.ExecuteScalar())
con.Close()
Return query
End Function
Public Sub DownloadScript()
Dim insertQry, updateQry As String, iDValues As String = ""
Dim i As Integer = 0
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim con As SqlConnection = New SqlConnection(conString)
Dim cmd As SqlCommand = New SqlCommand("select * from Estate_TR", con)
primaryKey = GetPrimaryKey(tableName, conString)
insertQry = ""
con.Open()
If File.Exists(Server.MapPath("~/" & tableName & ".sql")) Then
File.Delete(Server.MapPath("~/" & tableName & ".sql"))
End If
' Writing Create Table Script.
Dim sw As StreamWriter = New StreamWriter(Server.MapPath("~/" & tableName & ".sql"), True, Encoding.UTF8)
sw.Write(GenerateCreateTableScript() + Environment.NewLine)
sw.Close()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
i = i + 1
updateAdd = ""
insertQry = ""
Dim celldata As String = "", coulmenName As String = ""
For j As Integer = 0 To sdr.FieldCount - 1
If j > 0 Then
coulmenName += "," & sdr.GetName(j).ToString()
celldata += ",'" & sdr(j).ToString() & "'"
Else
coulmenName += sdr.GetName(j).ToString()
celldata += "'" & sdr(j).ToString() & "'"
End If
If primaryKey = sdr.GetName(j).ToString() Then
iDValues = sdr(j).ToString()
End If
If iDValues IsNot Nothing Then
updateQry = UpdateQuery(coulmenName, celldata, primaryKey, iDValues)
updateAdd += updateQry
insertQry = InsertQuery(coulmenName, celldata, tableName)
End If
Next
WriteScripts(tableName, insertQry, updateAdd, iDValues, primaryKey, i)
End While
If File.Exists(Server.MapPath("~/" & tableName & ".sql")) Then
Dim bytes As Byte() = File.ReadAllBytes(Server.MapPath("~/" & tableName & ".sql"))
File.Delete(Server.MapPath("~/" & tableName & ".sql"))
Response.Clear()
Response.Buffer = True
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = ContentType
Response.AppendHeader("Content-Disposition", "attachment; filename=" & tableName & ".sql")
Response.BinaryWrite(bytes)
Response.Flush()
Response.End()
End If
End Sub
Public Function GetPrimaryKey(ByVal tableName As String, ByVal cnnString As String) As String
Dim iD As String = ""
Dim con As SqlConnection = New SqlConnection(cnnString)
Dim cmd As SqlCommand = New SqlCommand("sp_pkeys", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@table_name", SqlDbType.NVarChar).Value = tableName
con.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
iD = sdr(3).ToString()
End While
con.Close()
Return iD
End Function
Public Sub WriteScripts(ByVal tableName As String, ByVal insertqry As String, ByVal updateQuery As String, ByVal iDValues As String, ByVal PrimaryKey As String, ByVal i As Integer)
Dim script As String = ""
updateQuery = "UPDATE " & tableName & " SET " & updateQuery & " WHERE " & PrimaryKey & " = ' " & iDValues & "'"
Dim index As Integer = updateQuery.LastIndexOf(",")
Dim updatqry As String = updateQuery.Remove(index, 1)
If i = 1 Then
script += "DECLARE @updateCount INT;" & Environment.NewLine
script += "DECLARE @insertCount INT;" & Environment.NewLine
script += "DECLARE @count INT;" & Environment.NewLine
script += " SET @updateCount = 0;" & Environment.NewLine
script += " SET @insertCount = 0;" & Environment.NewLine
script += "SELECT @count = COUNT(*) FROM [" & tableName & "] WHERE [" & PrimaryKey & "] = '" & iDValues & "'" & Environment.NewLine
script += "IF @count = 0" & Environment.NewLine
script += "BEGIN " & Environment.NewLine
script += "SET IDENTITY_INSERT " & tableName & " ON" & Environment.NewLine
script += insertqry & " " & Environment.NewLine
script += "SET IDENTITY_INSERT " & tableName & " OFF" & Environment.NewLine
script += " SET @insertCount = @insertCount + 1 " & Environment.NewLine
script += "END" & Environment.NewLine
script += "ELSE" & Environment.NewLine
script += "BEGIN" & Environment.NewLine
script += updatqry & "" & Environment.NewLine
script += " SET @updateCount = @updateCount + 1 " & Environment.NewLine
script += "END" & Environment.NewLine
Dim sw As StreamWriter = New StreamWriter(Server.MapPath("~/" & tableName & ".sql"), True, Encoding.UTF8)
sw.Write(script)
sw.Close()
Else
script += "SELECT @count = COUNT(*) FROM [" & tableName & "] WHERE [" & PrimaryKey & "] = '" & iDValues & "'" & Environment.NewLine
script += "IF @count = 0" & Environment.NewLine
script += "BEGIN " & Environment.NewLine
script += "SET IDENTITY_INSERT " & tableName & " ON" & Environment.NewLine
script += insertqry & "" & Environment.NewLine
script += "SET IDENTITY_INSERT " & tableName & " OFF" & Environment.NewLine
script += "SET @insertCount = @insertCount + 1 " & Environment.NewLine
script += "END" & Environment.NewLine
script += "ELSE" & Environment.NewLine
script += "BEGIN " & Environment.NewLine
script += updatqry & "" & Environment.NewLine
script += "SET @updateCount = @updateCount + 1 " & Environment.NewLine
script += "END" & Environment.NewLine
Dim sw As StreamWriter = New StreamWriter(Server.MapPath("~/" & tableName & ".sql"), True, Encoding.UTF8)
sw.Write(script)
sw.Close()
End If
End Sub
Public Function InsertQuery(ByVal columnName As String, ByVal cellData As String, ByVal tableName As String) As String
Return "INSERT INTO " & tableName & " (" & columnName & ") VALUES (" & cellData & ")"
End Function
Public Function UpdateQuery(ByVal columnName As String, ByVal cellData As String, ByVal Names As String, ByVal value As String) As String
Dim iDName, iDValue As String, ud As String = "", name As String = "", values As String = ""
iDName = Names
iDValue = value
If iDName IsNot Nothing Then
Dim indexcolumn As Integer = columnName.LastIndexOf(",")
Dim indexValues As Integer = cellData.LastIndexOf(",")
If indexcolumn > 0 AndAlso indexValues > 0 Then
columnName = columnName.Substring(indexcolumn)
cellData = cellData.Substring(indexValues)
name = columnName.Replace(",", "")
values = cellData.Replace(",", "")
If name <> iDName AndAlso values <> iDValue Then
ud = name & "=" & values & ","
End If
Else
name = columnName
values = cellData
If name <> iDName AndAlso values <> iDValue Then
ud = name & "=" & values & ","
End If
End If
End If
Return ud
End Function