Hi again guys...
Right, Having issue with a ADODB connection as I have never used one before. Currently trying to read files out of a folder using the ODBC connection that comes with the Software I want to extract data from.
I have managed to get the connection to the database and currently upto the part where I want to pass in SQL Statemnet
However, what should I use instead of the 'SqlDataAdapter', and the the 'Fill' option I Have done in the past with SQL Databases.
My code is below:
{
//**SAGE LINE 50 CONNECTION**\\
private ADODB.Connection adoConn = new ADODB.Connection();
private ADODB.Recordset adoRS = new ADODB.Recordset();
public Form1()
{
InitializeComponent();
}
//**SQL EXPRESS CONNECTION INFORMATION**\\
System.Data.SqlClient.SqlConnection con;
System.Data.SqlClient.SqlDataAdapter da;
DataSet ds1;
int inc = 0;
private void Form1_Load(object sender, EventArgs e)
{
//**ADODB CONNECTION INFORMATION**\\
adoConn = new ADODB.Connection();
adoRS = new ADODB.Recordset();
adoConn.Open("SageLine50v17", "Manager", "", 0);
string Sage50SQL = "SELECT SALES_LEDGER.ACCOUNT_REF,SALES_LEDGER.ADDRESS_1 FROM SALES_LEDGER";
//**SQL EXPRESS CONNECTION INFORMATION**\\
con = new System.Data.SqlClient.SqlConnection();
ds1 = new DataSet();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\MyWorkers.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
string sql = "SELECT * FROM tblWorkers";
da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
con.Open();
da.Fill(ds1, "Workers");
NavigationRecords();
con.Close();
}
private void NavigationRecords()
{
DataTable dtable = ds1.Tables["Workers"];
for (int i = 0; i < dtable.Rows.Count; i++)
{
DataRow dRow = ds1.Tables["Workers"].Rows[i];
ListViewItem item = new ListViewItem(dRow["first_Name"].ToString());
item.SubItems.Add(dRow["last_Name"].ToString());
item.SubItems.Add(dRow["job_Title"].ToString());
listView1.Items.Add(item);
}
}
Bascially I need the ADODB Connection to list all the data in a listview as before but the difference with this data set is it would be live and need refreshing each time the form is loaded.
I dont have much knowledge using ADO so any help would be great!
Kind Regards
Mark B.