Hi mhrglbdn!
The reason for your error is in the usage of the split function.
The way you described it you need to split on a comma not on a space.
Try correcting your code like this:
line.Split(new string[] { "," }, StringSplitOptions.None);
Since you were splitting on a space there are not enough parts in your array.
Modification
Since I found another error I'll just show the complete procedure:
void TextDateYukle()
{
using (StreamReader sr = new StreamReader(File.Open("C:\\Tr500.txt", FileMode.Open)))
{
using (SqlConnection txtbaglan = new SqlConnection("server=.;database=erisimik;trusted_connection=true"))
{
txtbaglan.Open();
string line = "";
while ((line = sr.ReadLine()) != "")
{
string[] parts = line.Split(new string[] { "," }, StringSplitOptions.None);
string cmdTxt = String.Format("INSERT INTO pdks(kod,il) VALUES ('{0}','{1}')", parts[0], parts[1]);
using (SqlCommand cmddd = new SqlCommand(cmdTxt, txtbaglan))
{
cmddd.ExecuteNonQuery();
}
}
}
}
}
End Modification
Cheers
Manfred