I have a service which when entering a number of an invoice brings me some fields and information, what I need to do is insert those same fields with the information to a sql table
I am what I have, the moment only brings me the data, but I do not know how to import them into sql
webserverDespacho.IntercambioSW service = new webserverDespacho.IntercambioSW();
DataTable dDataTable = service.aviso_despacho(TxtFactura.Text);
DataRow[] currentRows = dDataTable.Select(
null, null, DataViewRowState.CurrentRows);
if (currentRows.Length < 1)
System.Diagnostics.Debug.Write("No Current Rows Found");
else
{
foreach (DataColumn column in dDataTable.Columns)
System.Diagnostics.Debug.Write("\t{0}", column.ColumnName);
System.Diagnostics.Debug.WriteLine("\tRowState");
foreach (DataRow row in currentRows)
{
foreach (DataColumn column in dDataTable.Columns)
System.Diagnostics.Debug.Write("\t{0}","" + row[column]);
System.Diagnostics.Debug.WriteLine("\t" + row.RowState);
}
}
This way I'm trying to save the data in the sql table
string strCon = ConfigurationManager.ConnectionStrings["Sk_DBRadioFrecuencias"].ConnectionString;
SqlConnection conn = new SqlConnection(strCon);
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
for (int i = 0; dDataTable.Rows.Count > i; i++)
{
//insert Query
comm = "insert into SE_FactEmbarque (SE_Factura, SE_Almacen_Despacho, SE_Orden_De_Venta) values ('" + dDataTable.Rows[i]["factura"].ToString().Trim() + "','" +
dDataTable.Rows[i]["almacen_despacho"].ToString().Trim() + "','" + dDataTable.Rows[i]["ov"].ToString().Trim()+ "')";
}
But I'm getting an error.
and this is the information that the service brings me
<factura diffgr:id="factura1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
<factura>CD-00007</factura>
<almacen_despacho>CDIS</almacen_despacho>
<ov>OV238619</ov>
<oc>57-5776159</oc>
<fechaov>201503101130</fechaov>
<vendido_a>HOMCE33</vendido_a>
<ean_vendido_a>7703670900573</ean_vendido_a>
<cobrar_a>HOMCE33</cobrar_a>
<ean_cobrar_a>7703670900573</ean_cobrar_a>
<despachar_a>HOMCE33</despachar_a>
<ean_despachar_a>7703670900573</ean_despachar_a>
<nombre_despachar_a>HC Santa Marta</nombre_despachar_a>
<articulo>204804</articulo>
<descripcion>Lav S 55x43cm Grafado</descripcion>
<ean_articulo>7707021248048</ean_articulo>
<cantidad_facturada>6</cantidad_facturada>
<cantidad_pendiente>6</cantidad_pendiente>
<peso>2,2</peso>
<volumen>0,003</volumen>
</factura>