Re: Typed dataset - how to I alter SelectCommand

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This is the problem I'm having - it isn't altering the query so the whole
thing executes fine. I'm trying to alter the select (insert/delete/update)
commands within the table adapter generated along with the typed dataset but
I don't know how to 'break in' to the code.

I'm sure I must be missing something blindingly obvious but there's no
middle ground in the books I've read - either you use ADO directly to create
untyped data tables/sets (I'm comfortable with this) or you use the wizards
to created typed datasets/adapters. Nowhere seems to explain the process to
alter the table adapters using partial classes.

Much appreciated,

DG


"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:uATWghifGHA.4880@xxxxxxxxxxxxxxxxxxxxxxx
DG,

This looks crazy are you sure that the method is executed, at least there
should be an error in my opinion.

Cor

"DG" <djg2002@xxxxxxxxxxxxxx> schreef in bericht
news:e4t0nu$rme$1$830fa79d@xxxxxxxxxxxxxxxxxxx
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.
"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:Ob5xvwWfGHA.1272@xxxxxxxxxxxxxxxxxxxxxxx
DG,

You can at any moment before the fill change the Command (which is the
SelectCommand) in a DataAdapter

Cor

"DG" <djg2002@xxxxxxxxxxxxxx> schreef in bericht
news:e4q4pt$eq$1$8300dec7@xxxxxxxxxxxxxxxxxxx
Hi,

Can anyone advise how I alter the SelectCommand in an auto-generated
typed dataset programmatically? The select command would be part of a
search condition built by user inputs in the GUI.

Thanks,

DG









.



Relevant Pages

  • Re: IDC3203IITEM xxx DOES NOT ADHERE TO RESTRICTIONS
    ... I have a problem when I try run a job whit IDCAMS, in command ALTER, ... For IBM-MAIN subscribe / signoff / archive access instructions, ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)
  • Re: IDC3203IITEM xxx DOES NOT ADHERE TO RESTRICTIONS
    ... I have a problem when I try run a job whit IDCAMS, in command ALTER, ... For IBM-MAIN subscribe / signoff / archive access instructions, ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)
  • Re: Typed dataset - how to I alter SelectCommand
    ... Be aware that the strongly typed dataset class from 2.0 does look in nothing ... process to alter the table adapters using partial classes. ... you advise where I alter the command before filling the dataset? ... public partial class CustomersTableAdapter ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Ctrl, Shift & Alt (Over multiple forms)
    ... alter the behavior of command buttons. ... interface, showing captions describing the altered behaviors. ... Command buttons check Shift states and with KeyDown/KeyUp on the forms, ...
    (microsoft.public.vb.general.discussion)
  • Re: Altering Table - Adding Primary Key With References
    ... The CREATE TABLE command work fine. ... > let the primary key of the Child table be the referecing field. ... > can't do it with the ALTER TABLE command in VFP8. ... > ALTER TABLE Morechildren ADD FOREIGN KEY cid TAG cid1 REFERENCES Parents ...
    (microsoft.public.fox.vfp.dbc)