exception is =Input string was not in a correct format.Couldn't store
I fill data table from database and IL column type smallint i dont want to change column type nvarchar or anything else . How i can solve this problem .
My Code Here;
public DataTable getData(string komut)
{
DataTable dt = new DataTable();
cnn = connect.GetConnection();
sorgu = komut;
cmd = new SqlCommand(sorgu, cnn);
adap = new SqlDataAdapter(cmd);
adap.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Columns["IL"].ColumnName == "IL")
{
string tmpSehir;
iller.TryGetValue(dt.Rows[i]["IL"].ToString(), out tmpSehir);
dt.Rows[i]["IL"] = tmpSehir;
}
}
return dt;
}
Cenk IsikPosted Aug 2, 2012, 4:34 AM
Cenk IsikPosted Jul 30, 2012, 9:54 AM
VulpesPosted Jul 30, 2012, 9:49 AM
Another possibility would be store your city names using an integer code - if there are only a limited number of them you could define a Dictionary
Cenk IsikPosted Jul 30, 2012, 9:40 AM
VulpesPosted Jul 30, 2012, 9:10 AM
There's no way they can converted to integers which is why Int16.TryParse is returning zero for them.
Cenk IsikPosted Jul 30, 2012, 7:37 AM
VulpesPosted Jul 30, 2012, 7:11 AM
Cenk IsikPosted Jul 30, 2012, 6:19 AM
VulpesPosted Jul 30, 2012, 5:05 AM
Possible reasons include it being an empty string, containing a decimal point or thousand separator or being out of range.
I'd try printing out some values of tmpSehir to see what it actually contains.
Cenk IsikPosted Jul 30, 2012, 5:00 AM
VulpesPosted Jul 30, 2012, 4:47 AM