Community

How to call SQL Store Procedure to update the data set

 

ERROR Message:

[Processing error]:

SQLite error: no such column: __Id: SELECT _Id, _Name, _Street, _City, _State, _ZIP, _CountryCode, _VATID, _EmailAddress, __City, __Street, __Name, __Id, __EmailAddress, __State, __ZIP, __CountryCode, __VATID, __FCInternalId FROM Main WHERE __FCIsInvalid=0

 

 Script

using System;

using System.IO;

using Microsoft.VisualBasic.FileIO;

using System.Collections.Generic;

using System.Data;

using System.Data.SqlClient;

 

try

{

        SqlConnection sqlConnection = new SqlConnection();

sqlConnection.ConnectionString = "Data Source=*******;Initial Catalog=******;Integrated Security=True;";

sqlConnection.Open();

SqlCommand cmd = new SqlCommand("GetCompanies", sqlConnection);

cmd.CommandType = CommandType.StoredProcedure;

 

SqlDataReader rdr = cmd.ExecuteReader();

IDataSetRecord rec = DataSet.CreateRecord();

while (rdr.Read())

{

string strBUId = rdr["BUId"].ToString().Trim();

string strEmailAddress = rdr["EmailAddress"].ToString().Trim();

string strName = rdr["Name"].ToString().Trim();

string strAddressLine1 = rdr["AddressLine1"].ToString().Trim();

string strAddressLine2 = rdr["AddressLine2"].ToString().Trim();

string strAddressLine3 = rdr["AddressLine3"].ToString().Trim();

string strAddressLine4 = rdr["AddressLine4"].ToString().Trim();

string strCity = rdr["City"].ToString().Trim();

string strState = rdr["State"].ToString().Trim();

string strPostcode = rdr["Postcode"].ToString().Trim();

string strCountry = rdr["Country"].ToString().Trim();

string strTaxNumber = rdr["TaxNumber"].ToString().Trim(); 

rec.AddValue("Id", strBUId);

rec.AddValue("EmailAddress", strEmailAddress); //EmailAddress

rec.AddValue("Name", strName);

rec.AddValue("Street", strAddressLine1 + " " + strAddressLine2 + " " + strAddressLine3 + " " + strAddressLine4);

rec.AddValue("City", strCity);

rec.AddValue("State", strState);

rec.AddValue("ZIP", strPostcode); //Postcode

rec.AddValue("CountryCode", strCountry);

rec.AddValue("VATID", strTaxNumber);

 

dataSet.AddRecord(rec);

 

}

 

        sqlConnection.Close();

}

catch (Exception ex)

{

 

}

 

     

0

Comments

0 comments

Please sign in to leave a comment.