Passing a custom sql command

Magezi SagesseMagezi Sagesse DRCONGO
edited 8:23PM in FastReport .NET
I have a problem with passing a custom sql command, I don't know how to pass parameters to tabledatasource selectcommand as it can be done with oledbcommand.parameters.add(.....), working without that is handling error when I the where condition data has an apostrophy.

Example: table.selectcommand="select * from listetous where objsup='l'homme'" with oledbcommand it works when I use parameter :
oledbcommand.commandtext= ="select * from listetous where objsup=a"
oledbcommand.parameters.add("a",oledbvarchar,255).value= "l'homme"

Can someone help me showing me how to use parameters with tabledatasource?

thank you!!!

Comments

  • Magezi SagesseMagezi Sagesse DRCONGO
    edited 8:23PM
    I have a problem with passing a custom sql command, I don't know how to pass parameters to tabledatasource selectcommand as it can be done with oledbcommand.parameters.add(.....), working without that is handling error when I the where condition data has an apostrophy.

    Example: table.selectcommand="select * from listetous where objsup='l'homme'" with oledbcommand it works when I use parameter :
    oledbcommand.commandtext= ="select * from listetous where objsup=a"
    oledbcommand.parameters.add("a",oledbvarchar,255).value= "l'homme"

    Can someone help me showing me how to use parameters with tabledatasource?

    thank you!!!

    I have gotten the solution :

    what I did was to declare a fastreport commandparameter, I passed the value to that parameter and added the parameter to the tabledatasource paramtercollection


    'Declaration of the parameter
    dim p as new fastreport.commandparameter
    'name of the parameter
    p.name=a
    'parameter data type 
    p.datatype = oledb.datatype.varchar
    'passing a value to the parameter
    p.value ="l'homme"
    'defining the size of data
    p.size =50
    
    table.parameters.add(p)
    
  • edited 8:23PM
    using FastReport.Data;

    report1.Load("report1.frx");
    TableDataSource table = report1.GetDataSource("Table1") as TableDataSource;
    table.SelectCommand = "SELECT * FROM CUSTOMERS";
    report1.Show();

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.