Hi Guys,
I am trying to insert hashtable in databse but one of the key in hashtable is null.Can anyone help me write an exception for this.Or if i can just move to the next key .
Thanks a lot
private void btnUrdu_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(@"Server=208.124.179.197;Database=RTLUser;UID=sa;");
DataSet CustomersDataSet = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommandBuilder cmdBuilder;
string myString;
DataSet ds = new DataSet();
//cn.ConnectionString = "Server=server;Database=RTLUser;UID=sa;";
cn.Open();
SimpleUrduDict.SimpleUrduDictionary ins = new SimpleUrduDictionary();
Hashtable aaa = ins.AllWords();
StringBuilder insertCommand = new StringBuilder();
IDictionaryEnumerator en = aaa.GetEnumerator();
if (aaa.Count > 0)
{
while (en.MoveNext())
{
string al = en.Value.ToString();
string al2 = en.Key.ToString();
string al3 = "";
string al4 = "";
al3 = al.Replace("'", "''");
al4 = al2.Replace("'", "''");
myString = @"INSERT INTO TblUrdu (word,definition) Values('" + al4 + "','" + al3 + "')";
SqlCommand myCmd = new SqlCommand(myString, cn);
myCmd.ExecuteNonQuery();
}
}
cn.Close();