bir xml dosyasındaki verileri çekip sql server üzerindeki veritabanıma atmaya çalışıyorum. ancak bi sorunum var. xml datasetinden veriyi alıp verityabanına atarken string veriyi floata çevirirken hata veriyor. hata mesajı ve kullandığım kod aşağıda:
Kullandığım Kod:
Kod: Tümünü seç
ds.ReadXml("http://www.xxxxxxxx.com/Cihad/l.xml");
DataGrid1.DataBind();
Label1.Text=ds.Tables[0].Rows.Count.ToString();
int i=0;
sqlConn.Open();
while(ds.Tables[0].Rows.Count-1>=i)
{
sqlInsertCommand1.CommandText="insert into URUN (sANAGRUPKOD, sANAGRUPAD, sALTGRUPKOD, sALTGRUPAD, sKOD, sURUNAD, sDOVIZID, sSKFIYAT, sBFIYAT, sKFIYAT, sMIKTAR, sGARANTI, sMARKA) values ( '" + ds.Tables[0].Rows[i][0].ToString() + "' , '" + ds.Tables[0].Rows[i][1].ToString() + "' , '" + ds.Tables[0].Rows[i][2].ToString() + "' , '" + ds.Tables[0].Rows[i][3].ToString() + "' , '" + ds.Tables[0].Rows[i][4].ToString() + "' , '" + ds.Tables[0].Rows[i][5].ToString().Replace("'","''''") + "' , '" + Convert.ToInt32(ds.Tables[0].Rows[i][6].ToString())+ "' , '" + System.Convert.ToDouble(ds.Tables[0].Rows[i][7].ToString()) +"' , '"+ System.Convert.ToDouble(ds.Tables[0].Rows[i][8].ToString())+"' , '"+System.Convert.ToDouble(ds.Tables[0].Rows[i][9].ToString())+"' , '" + ds.Tables[0].Rows[i][10].ToString() + "' , '" + Convert.ToInt32(ds.Tables[0].Rows[i][11].ToString()) + "' , '" + ds.Tables[0].Rows[i][12].ToString() + "' )";
sqlInsertCommand1.ExecuteNonQuery();
i++;
}
sqlConn.Close();
Kod: Tümünü seç
Error converting data type varchar to float.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Error converting data type varchar to float.
Source Error:
Line 39: {
Line 40: sqlInsertCommand1.CommandText="insert into URUN (sANAGRUPKOD, sANAGRUPAD, sALTGRUPKOD, sALTGRUPAD, sKOD, sURUNAD, sDOVIZID, sSKFIYAT, sBFIYAT, sKFIYAT, sMIKTAR, sGARANTI, sMARKA) values ( '" + ds.Tables[0].Rows[i][0].ToString() + "' , '" + ds.Tables[0].Rows[i][1].ToString() + "' , '" + ds.Tables[0].Rows[i][2].ToString() + "' , '" + ds.Tables[0].Rows[i][3].ToString() + "' , '" + ds.Tables[0].Rows[i][4].ToString() + "' , '" + ds.Tables[0].Rows[i][5].ToString().Replace("'","''''") + "' , '" + Convert.ToInt32(ds.Tables[0].Rows[i][6].ToString())+ "' , '" + System.Convert.ToDouble(ds.Tables[0].Rows[i][7].ToString()) +"' , '"+ System.Convert.ToDouble(ds.Tables[0].Rows[i][8].ToString())+"' , '"+System.Convert.ToDouble(ds.Tables[0].Rows[i][9].ToString())+"' , '" + ds.Tables[0].Rows[i][10].ToString() + "' , '" + Convert.ToInt32(ds.Tables[0].Rows[i][11].ToString()) + "' , '" + ds.Tables[0].Rows[i][12].ToString() + "' )";
Line 41: sqlInsertCommand1.ExecuteNonQuery();
Line 42:
Line 43: i++;
Source File: d:\webspaces\wwwroot\1\default.aspx.cs Line: 41