Author: emr_akar | Posted on: 8/10/2010 10:14:35 AM | Views : 231

 
Hi everybody could you check my code please when i try to insert splitted data into the db i get an execption Index was outside the bounds of the array. What am i doing wrong void TextDataYukle() { StreamReader sr = new StreamReader("c:\\iller.txt"); string[] param = new string[] { "" }; string line = ""; while ((line = sr.ReadLine()) != "") { string[] parts = line.Split(param, StringSplitOptions.None); string cmdTxt = String.Format("INSERT INTO iller(kod, il) VALUES('{0}','{1}')", parts[0], parts[1]); SqlConnection conn = new SqlConnection("Data Source=localhost.\\sqlexpress;Initial Catalog=plaka;integrated Security=sspi"); SqlCommand cmd = new SqlCommand(cmdTxt, conn); cmd.ExecuteNonQuery(); ...

Go to the complete details ...