Please tell me what is wri=ong

A

Adrian

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Common;
namespace trial_a
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
string connect_string = "SELECT * FROM Customers, Invoice";
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = "server = fred\\sqlexpress; database
= newdb;integrated security = true";
using (SqlDataAdapter da = new
SqlDataAdapter(connect_string, conn))
{
using (DataSet ds = new DataSet())
{
da.TableMappings.Add("Table", "Customers");
da.TableMappings.Add("Table1","Invoice");
da.Fill(ds,"Table");

try
{
DataTable dt1 = ds.Tables[0];
DataTable dt2 = ds.Tables[1];
textBox1.Text =
dt1.Rows[0].ItemArray[0].ToString();
textBox2.Text =
dt2.Rows[0].ItemArray[0].ToString();
}
catch (Exception x)
{
MessageBox.Show(x.Message);
}
}
}
}

}
}
}
 
A

Adrian

Yes, that was wrong.
Thank you.
Adrian.

Earl said:
SELECT * FROM Customers, Invoice

Adrian said:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Common;
namespace trial_a
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
string connect_string = "SELECT * FROM Customers, Invoice";
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = "server = fred\\sqlexpress;
database = newdb;integrated security = true";
using (SqlDataAdapter da = new
SqlDataAdapter(connect_string, conn))
{
using (DataSet ds = new DataSet())
{
da.TableMappings.Add("Table", "Customers");
da.TableMappings.Add("Table1","Invoice");
da.Fill(ds,"Table");

try
{
DataTable dt1 = ds.Tables[0];
DataTable dt2 = ds.Tables[1];
textBox1.Text =
dt1.Rows[0].ItemArray[0].ToString();
textBox2.Text =
dt2.Rows[0].ItemArray[0].ToString();
}
catch (Exception x)
{
MessageBox.Show(x.Message);
}
}
}
}

}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top