Cor - here's the method I tried but it isn't working - the query should
crash this code (because it doesn't exist) but the code runs fine. Can you
advise where I alter the command before filling the dataset?
Thanks,
DG
using System;
using System.Data;
using System.Data.SqlClient;
namespace NorthwindDataAccess.CustomersDataSetTableAdapters
{
public partial class CustomersTableAdapter
{
public void UpdateSelectCommand()
{
SqlConnection conn = new
SqlConnection(NorthwindDataAccess.Properties.Settings.Default.NorthwindConnectionString);
SqlCommand cmd = new SqlCommand("customer_qry", conn);
cmd.CommandType = CommandType.StoredProcedure;
this.Adapter.SelectCommand = cmd;
}
}
}
And try to call this code from Form1 as follows:-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NorthwindDataAccess.CustomersDataSetTableAdapters;
using NorthwindDataAccess;
namespace NorthwindGUI
{
public partial class Form1 : Form
{
CustomersTableAdapter m_Adapter = new CustomersTableAdapter();
CustomersDataSet m_Customer = new CustomersDataSet();
public Form1()
{
InitializeComponent();
}
private void OnFormLoad(object sender, EventArgs e)
{
m_Adapter.UpdateSelectCommand();
// This shouldn't work as there is no 'customer_qry'
stored proc in the database
// - but it does...
m_Adapter.Fill(m_Customer.Customers);
...etc...
}
The 'UpdateSelectCommand' doesn't have any effect on the adapters select
command.