Ih have a problem, im trying to read data from an access database and insert the same data into a sql server database,before some validations, i am trying to do this dinamacly, and in visual c#
i already made this code
using System;
using System.Reflection;
using System.Data;
using System.Data.OleDb;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Runtime.InteropServices;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Text;
namespace ADO.net
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
string strConn, strSQL, txtError, sqlCon, sqlstrSQL;
txtError= "";
int intError;
int intSucesso350A;
intError = 0;
intSucesso350A = 0;
//SQL
sqlCon ="server=#####;uid=sa;initial catalog=#####";
sqlstrSQL = "SELECT * from tbltemp";
SqlDataAdapter daSQL = new SqlDataAdapter(sqlstrSQL, sqlCon);
DataSet dsSQL = new DataSet();
try
{
daSQL.Fill(dsSQL);
}
catch (Exception a)
{
Console.WriteLine(a.Message);
}
DataTable tblSQL = dsSQL.Tables[0];
/*foreach(DataRow row in tblSQL.Rows)
{
Console.Write("AQUI E IMPORTANTE " + row["lngContestId"] + "FIM ");
}*/
//Access
//TblAdjudicacoesVortalError = 0;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\teste\\teste.mdb";
strSQL = "SELECT * from tbl";
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strConn);
DataSet ds = new DataSet();
try
{
da.Fill(ds);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
DataTable tbl = ds.Tables[0];
foreach (DataRow row in tbl.Rows)
{
if (row["IDConc"].ToString()=="0" || row["IDConc"].ToString() == null)
{
txtError= txtError+ row["IDConc"].ToString() + ", " + row["codAdj"].ToString() + ", O campo IDConc é vazio";
intError = intError + 1;
Console.WriteLine(txtError);
}
if (row["CodAdj"].ToString()=="0" || row["CodAdj"].ToString() == null)
{
txtErrorTbl= txtError+ ", " + row["IDConc"] + ", " + row["codAdj"].ToString() + ", O campo CodAdj é vazio";
intError = intError + 1;
Console.WriteLine(txtErrorTbl);
}
}
if (intError == 0)
{
Console.WriteLine(intError);
intSucesso350A = intSucesso350A + 1;
Console.WriteLine(intSucesso350A);
}
else
{
foreach (DataRow row in tbl.Rows)
{
try
it's possible to do this