﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » How to use parameters rather string statement</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 14 Sep 2026 14:37:46 GMT</lastBuildDate><ttl>20</ttl><item><title>How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24872.aspx</link><description>Hi&lt;/P&gt;&lt;P&gt;I have this:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;FONT color=#000000&gt;currenthmonth &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;FONT color=#000000&gt;currentyear &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;FONT color=#000000&gt;currenthmonth &lt;/FONT&gt;= &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Date&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Now.Month&lt;/P&gt;&lt;P&gt;&lt;FONT color=#000000&gt;currentyear &lt;/FONT&gt;= &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Date&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Now.Year&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.FillDataTable(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"SELECT * FROM Sales WHERE Payment = 1 AND Month(DatePay) ="&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &amp;amp; currenthmonth &amp;amp; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;" AND Year(DatePay)="&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &amp;amp;&amp;nbsp;currentyear &amp;amp; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;""&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;But I read that in SF help that is best use paramaters, I have used parameters in other queries and not problem with boolean fields, but I can not make it work using the Month function. I need this for recover only sales orders for current month and year.&lt;/P&gt;&lt;P&gt;Kindest regards.</description><pubDate>Wed, 07 Oct 2009 12:17:32 GMT</pubDate><dc:creator>Juan Carlos Pazos</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24886.aspx</link><description>Glad you got it working. Once you understand it, this is pretty straight forward. :D</description><pubDate>Wed, 07 Oct 2009 12:17:32 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24885.aspx</link><description>Thanks Greg&lt;P&gt;I follow your explanetion and finally get this work. Here is the final code:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; FillVentasMes()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'-- Establish locals&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; currentmonth &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Date&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Now.Month&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; currentyear &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Date&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Now.Year&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; loCommand &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; SqlCommand()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'-- Build the query&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;loCommand.CommandText = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"SELECT * FROM Pedidos WHERE Pagada = 1 AND Month(FechaPago) = @pCurrentMonth AND Year(FechaPago)= @pCurrentYear"&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'-- Add the parameter&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;loCommand.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"@pCurrentMonth"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, SqlDbType.Int)&lt;/P&gt;&lt;P&gt;loCommand.Parameters(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"@pCurrentMonth"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;).Value = currentmonth&lt;/P&gt;&lt;P&gt;loCommand.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"@pCurrentYear"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, SqlDbType.Int)&lt;/P&gt;&lt;P&gt;loCommand.Parameters(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"@pCurrentYear"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;).Value = currentyear&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'-- Execute the command to fill the business object&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.FillDataTable(loCommand)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;Regards</description><pubDate>Wed, 07 Oct 2009 01:15:49 GMT</pubDate><dc:creator>Juan Carlos Pazos</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24883.aspx</link><description>I think you're just missing it by a bit here Juan.&lt;br&gt;
&lt;br&gt;
Two things are going on:&lt;br&gt;
&lt;br&gt;
1. You are creating a SqlCommand object, that will become a SQL statement that is executed on SQL Server:&lt;br&gt;
&lt;br&gt;
[codesnippet]Using cmd As New SqlCommand&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- This builds a sql string (see below)&lt;br&gt;
&amp;nbsp;&amp;nbsp;Dim strSQLStringWithParameters = "SELECT *"&lt;br&gt;
&amp;nbsp;&amp;nbsp;strSQLStringWithParameters &amp;= " FROM Sales"&lt;br&gt;
&amp;nbsp;&amp;nbsp;strSQLStringWithParameters &amp;= " WHERE Payment = 1"&lt;br&gt;
&amp;nbsp;&amp;nbsp;strSQLStringWithParameters &amp;= "   AND Month(DatePay) = @pCurrenthMonth -- parameter"&lt;br&gt;
&amp;nbsp;&amp;nbsp;strSQLStringWithParameters &amp;= "   AND Year(DatePay)= @pCurrentYear -- parameter"[/codesnippet]&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
This will end up as the following SQL statement:&lt;br&gt;
&lt;br&gt;
[codesnippet]SELECT *&lt;br&gt;
FROM Sales&lt;br&gt;
WHERE Payment = 1&lt;br&gt;
AND Month(DatePay) = @pCurrentMonth -- parameter&lt;br&gt;
AND Year(DatePay) = @pCurrentYear -- parameter[/codesnippet]&lt;br&gt;
&lt;br&gt;
2. You are defining the values used by the parameters. Here you define parameters that will end up in SQL, with values you are providing via .NET variables.&lt;br&gt;
[codesnippet]&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- This defines what the parameters are for the SQL string&lt;br&gt;
&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;&amp;nbsp;The parameter name, @pCurrentMonth &amp; @pCurrentYear, must match parameter used in SQL statement above.&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters.AddWithValue("@pCurrenthMonth", currenthmonth).SqlDbType = SqlDbType.Int&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters.AddWithValue("@pCurrentYear", currentyear).SqlDbType = SqlDbType.Int&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- fill table&lt;br&gt;
End Using[/codesnippet]&lt;br&gt;
&lt;br&gt;
Note that currentmonth and currentyear are just .net variables. You can pass them into the fill method or pass in a date and then get the month/year or as you originally showed, just use the current date.  They are just .NET variables, handled however makes sense in your situation.&lt;br&gt;
&lt;br&gt;
No matter how you load up the currentmonth/currentyear variables, their values are passed along to SQL Server as parameters. The Parameters.AddWithValue methods essentially gets translated into SQL again (assuming that currentmonth was set to 10 and currentyear was 2009:&lt;br&gt;
&lt;br&gt;
[codesnippet]Declare @pCurrentMonth int&lt;br&gt;
Declare @pCurrentYear int&lt;br&gt;
Set @pCurrentMonth = 10&lt;br&gt;
Set @pCurrentYear = 2009[/codesnippet]&lt;br&gt;
&lt;br&gt;
The important thing is that you define parameters within the SQL statement (" AND Month(DatePay) = @pCurrentMonth") and then also define a parameter of the correct SQL data type with the same name ("cmd.Parameters.AddWithValue("@pCurrentMonth", currentmonth)").</description><pubDate>Tue, 06 Oct 2009 23:57:24 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24882.aspx</link><description>[quote][b]Juan Carlos Pazos (10/06/2009)[/b][hr]Where does @pCurrentMonth and @pCurrentYear come from?[/quote]&lt;br&gt;
&lt;br&gt;
It is coming from your code in [url=]http://forum.strataframe.net/FindPost24872.aspx[/url] in your sample you declare those variables, I simply use it as a sample, but you have to provide their values.&lt;br&gt;</description><pubDate>Tue, 06 Oct 2009 20:25:44 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24881.aspx</link><description>Hi Edhy&lt;/P&gt;&lt;P&gt;&lt;TABLE cellSpacing=0 cellPadding=0 width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=smalltxt vAlign=top&gt;&lt;P&gt;This is the code you give as sample:&lt;/P&gt;&lt;P&gt;&lt;DIV style="BORDER-BOTTOM: #000080 1px dashed; BORDER-LEFT: #000080 1px dashed; PADDING-BOTTOM: 10px; BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-FAMILY: Courier New, Verdana; COLOR: #000080; MARGIN-LEFT: 20px; FONT-SIZE: 8pt; BORDER-TOP: #000080 1px dashed; MARGIN-RIGHT: 20px; BORDER-RIGHT: #000080 1px dashed; PADDING-TOP: 10px"&gt;Using cmd As New SqlCommand&lt;BR&gt;Dim strSQLStringWithParameters = "SELECT * FROM Sales WHERE Payment = 1 AND Month(DatePay) = @pCurrenthMonth AND Year(DatePay)= @pCurrentYear"&lt;BR&gt;cmd.Parameters.AddWithValue("@pCurrenthMonth", currenthmonth).SqlDbType = SqlDbType.Int&lt;BR&gt;cmd.Parameters.AddWithValue("@pCurrentYear", currentyear).SqlDbType = SqlDbType.Int&lt;BR&gt;Me.FillDataTable(strSQLStringWithParameters)&lt;BR&gt;End Using&lt;/DIV&gt;&lt;P&gt;My question is this:&lt;/P&gt;&lt;P&gt;Where does @pCurrentMonth and @pCurrentYear come from?&lt;/P&gt;&lt;P&gt;Sales is the table, Payment is a boolean field, Month(DatePay) and Year(DatePay) are functions to retrieve the month and year from the DatePay field in the sales table.&lt;/P&gt;&lt;P&gt;But in cmd.Parameters.AddWithValue("@CurrenthMonth", currenthmonth).SqlDbType = SqlDBType.Int you use this: "@pCurrentMonth" (same for the year part). I can not find where to declare this.&lt;/P&gt;&lt;P&gt;The error message shows this:&lt;/P&gt;&lt;P&gt;Debe declarar la variable escalar "@pCurrentMonth"&lt;/P&gt;&lt;P&gt;Hope it makes more sense.&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Regards&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description><pubDate>Tue, 06 Oct 2009 19:43:05 GMT</pubDate><dc:creator>Juan Carlos Pazos</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24880.aspx</link><description>Hi Juan,&lt;br&gt;
&lt;br&gt;
I have no idea what are you asking form.  Please re-read your post and re-phrase it.&lt;br&gt;
&lt;br&gt;
By the way, did you try the code?</description><pubDate>Tue, 06 Oct 2009 19:27:04 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24879.aspx</link><description>Hi Edhy and Greg&lt;/P&gt;&lt;P&gt;I will use this:&lt;/P&gt;&lt;P&gt;[codesnippet]Using cmd As New SqlCommand&lt;BR&gt;Dim strSQLStringWithParameters = "SELECT * FROM Sales WHERE Payment = 1 AND Month(DatePay) = @pCurrenthMonth AND Year(DatePay)= @pCurrentYear"&lt;BR&gt;cmd.Parameters.AddWithValue("@pCurrenthMonth", currenthmonth).SqlDbType = SqlDbType.Int&lt;BR&gt;cmd.Parameters.AddWithValue("@pCurrentYear", currentyear).SqlDbType = SqlDbType.Int&lt;BR&gt;Me.FillDataTable(strSQLStringWithParameters)&lt;BR&gt;End Using[/codesnippet]&lt;/P&gt;&lt;P&gt;But where comes this: @pCurrenthMonth&amp;nbsp; and "@pCurrentYear?&lt;/P&gt;&lt;P&gt;I think they should be here:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; FillMonthSales()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;But I can figure it out, because og this: &amp;nbsp;FillMonthSales(ByVal DatePay as ....)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;I litle more help please.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Regards&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Tue, 06 Oct 2009 18:13:32 GMT</pubDate><dc:creator>Juan Carlos Pazos</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24875.aspx</link><description>If the data comes from a user, you want to use the second option (with parameters). The method you initially showed and the first one Edhy showed are both vulnerable to SQL Injection attacks.&lt;br&gt;
&lt;br&gt;
Also, parametrized queries I believe allow for the query plan to be cached, thus they are faster.&lt;br&gt;
&lt;br&gt;
Mostly for the first reason, [b]all[/b] of my sql statements are parametrized.</description><pubDate>Tue, 06 Oct 2009 14:49:20 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to use parameters rather string statement</title><link>http://forum.strataframe.net/FindPost24873.aspx</link><description>Hi Juan Carlos,&lt;br&gt;
&lt;br&gt;
Here are 2 ways of getting the same result.  I prefer the 2nd one.&lt;br&gt;
&lt;br&gt;
[quote]&lt;br&gt;
  '-- Sample 1&lt;br&gt;
        Dim currenthmonth As Integer = Date.Now.Month&lt;br&gt;
        Dim currentyear As Integer = Date.Now.Year&lt;br&gt;
        Dim strSQLString = String.Format("SELECT * FROM Sales WHERE Payment = 1 AND Month(DatePay) = {0} AND Year(DatePay)= {1}", currenthmonth.ToString, currentyear.ToString)&lt;br&gt;
        Me.FillDataTable(strSQLString)&lt;br&gt;
&lt;br&gt;
        '-- Sample 2&lt;br&gt;
        Using cmd As New SqlCommand&lt;br&gt;
            Dim strSQLStringWithParameters = "SELECT * FROM Sales WHERE Payment = 1 AND Month(DatePay) = @pCurrenthMonth AND Year(DatePay)= @pCurrentYear"&lt;br&gt;
            cmd.Parameters.AddWithValue("@pCurrenthMonth", currenthmonth).SqlDbType = SqlDbType.Int&lt;br&gt;
            cmd.Parameters.AddWithValue("@pCurrentYear", currentyear).SqlDbType = SqlDbType.Int&lt;br&gt;
            Me.FillDataTable(strSQLStringWithParameters)&lt;br&gt;
        End Using&lt;br&gt;
[/quote]</description><pubDate>Tue, 06 Oct 2009 12:26:17 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>