How i can select data from stored proc and insert them to file.dbf, using c#? Some code that i have:
OleDbConnection lDbfConnection = new OleDbConnection(connectionString);
try
{
lDbfConnection.Open();
OleDbParameter lScript = new OleDbParameter(
"script",
@"create table Result (colums parameters)
OleDbCommand lOleDbCommand = lDbfConnection.CreateCommand();
lOleDbCommand.CommandType = CommandType.StoredProcedure;
lOleDbCommand.CommandText = "ExecScript";
lOleDbCommand.Parameters.Add(lScript);
lOleDbCommand.ExecuteNonQuery();
lOleDbCommand = lDbfConnection.CreateCommand();
lOleDbCommand.CommandText = "insert into Result(colums)
//code that i need
SqlConnection lProcConnection = new SqlConnection(lConnect);
SqlCommand lCommand = new SqlCommand(lProcName, lProcConnection);
lCommand.CommandType = CommandType.StoredProcedure;
//input parameters
lCommand.Parameters.Add("ParamName", SqlDbType.Type).Value =SomeValue;
lProcConnection.Open();
......
You can use VfpClient to help you.
Here is an example:
using(var connection = new SqlConnection("connectionString")) {
using(var command = connection.CreateCommand()) {
command.CommandText = "storedProcedure";
command.CommandType = CommandType.StoredProcedure;
var data = new DataTable("TableName");
// This will execute the stored procedure and put the data in a data table.
var adapter = new SqlDataAdapter(command);
adapter.Fill(data);
// This will create a dbc.
var dbc = @"c:\Data\Data.dbc";
var dbcCreator = new VfpClient.Utils.DbcCreator.DataTableDbcCreator(dbc);
// This will create a dbf with the data retrieved from the stored procedure.
dbcCreator.Add(data);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.