{"id":1506,"date":"2011-09-16T08:00:39","date_gmt":"2011-09-16T12:00:39","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=1506"},"modified":"2011-09-16T11:12:30","modified_gmt":"2011-09-16T15:12:30","slug":"vb-net-parameters","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2011\/09\/vb-net-parameters\/","title":{"rendered":"VB.NET &#8211; Parameters"},"content":{"rendered":"<blockquote><p>Parameter default value in code behind<\/p><\/blockquote>\n<pre>\r\nSQL Datasource\r\n<code>\r\n&lt;asp:sqldatasource ID=\"ServiceExpired\" runat=\"server\" \r\n       ConnectionString=\"< %$ ConnectionStrings:intranetConnectionString2 %>\" \r\n       SelectCommand=\"SELECT * FROM [Invoice] _\r\n                      WHERE _\r\n                           ([EXPIRATION_DATE] >= @EXP_BEG) _\r\n                      AND _\r\n                           ([EXPIRATION_DATE] < @EXP_END) _\r\n                      AND \r\n                           ([EXPIRATION_CONTACT] = @EXPIRATION_CONTACT) _\r\n                      ORDER BY _\r\n                             EXPIRATION_DATE \">\r\n&lt;selectparameters>\r\n      &lt;asp:parameter DefaultValue=\"YES\" Name=\"EXPIRATION_CONTACT\" Type=\"String\" \/>\r\n      &lt;asp:parameter Name=\"EXP_BEG\" Type=\"DateTime\"\/>\r\n      &lt;asp:parameter Name=\"EXP_END\" Type=\"DateTime\"\/>\r\n&lt;\/selectparameters>\r\n<\/code>\r\nCode behind\r\n<code>\r\nProtected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load\r\n  CuMonthLbl.Text = MonthName(Date.Now.Month)     ' - current month name\r\n  NxMonthLbl.Text = MonthName(Date.Now.Month + 1) ' - next to current month name\r\n  Dim NxMonth As String                           ' - define next month value\r\n      NxMonth = (Date.Now.Month + 1)\r\n ' - query range labels\r\n  MoBegLbl.Text = DateTime.Now.Month.ToString() _\r\n                    + \"\/1\/\" + DateTime.Now.Year.ToString()\r\n  MoEndLbl.Text = NxMonth + \"\/1\/\" + DateTime.Now.Year.ToString()\r\n\r\n' - parameters values\r\n' - beginning of month\r\n  ServiceExpired.SelectParameters(\"EXP_BEG\").DefaultValue = _\r\n                                             DateTime.Now.Month.ToString() _\r\n                                   + \"\/1\/\" + DateTime.Now.Year.ToString() \r\n' - end of month\r\n  ServiceExpired.SelectParameters(\"EXP_END\").DefaultValue = _\r\n                                             NxMonth _\r\n                                   + \"\/1\/\" + DateTime.Now.Year.ToString()\r\nEnd Sub\r\n\r\n' - label\r\nCurrent month: &lt;asp:label ID=\"CuMonthLbl\" runat=\"server\"> -\r\nNext monht:  &lt;asp:label ID=\"NxMonthLbl\" runat=\"server\">\r\nRecords from: &lt;asp:label ID=\"MoBegLbl\" runat=\"server\"> -\r\n              &lt;asp:label ID=\"MoEndLbl\" runat=\"server\">\r\n' - output\r\n<\/code>\r\n--------------------------------------------------------\r\n|  #  | Company Name | Location | Expire     | Contact |\r\n--------------------------------------------------------\r\n|  1  | Kiklop       | Europe   | 09\/01\/2011 | YES     |\r\n|  2  | Acer         | Europe   | 09\/09\/2011 | YES     |\r\n|  3  | King Z       | Africa   | 09\/22\/2011 | YES     |\r\n|  4  | Chung Fu     | Asia     | 09\/30\/2011 | YES     |\r\n\r\nCurrent month: September\r\nNext month: October\r\nRecords from: 09\/01\/2011 - 10\/01\/2011\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Parameter default value in code behind SQL Datasource &lt;asp:sqldatasource ID=&#8221;ServiceExpired&#8221; runat=&#8221;server&#8221; ConnectionString=&#8221;< %$ ConnectionStrings:intranetConnectionString2 %>&#8221; SelectCommand=&#8221;SELECT * FROM [Invoice] _ WHERE _ ([EXPIRATION_DATE] >= @EXP_BEG) _ AND _ ([EXPIRATION_DATE] < @EXP_END) _ AND ([EXPIRATION_CONTACT] = @EXPIRATION_CONTACT) _ ORDER BY _ EXPIRATION_DATE \"> &lt;selectparameters> &lt;asp:parameter DefaultValue=&#8221;YES&#8221; Name=&#8221;EXPIRATION_CONTACT&#8221; Type=&#8221;String&#8221; \/> &lt;asp:parameter Name=&#8221;EXP_BEG&#8221; Type=&#8221;DateTime&#8221;\/> &lt;asp:parameter Name=&#8221;EXP_END&#8221; Type=&#8221;DateTime&#8221;\/> &lt;\/selectparameters> [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,16,32],"tags":[19,42,62],"class_list":["post-1506","post","type-post","status-publish","format-standard","hentry","category-applications","category-net","category-ms-sql","tag-asp-net","tag-gridview","tag-parameters"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1506"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=1506"}],"version-history":[{"count":23,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1506\/revisions"}],"predecessor-version":[{"id":1529,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1506\/revisions\/1529"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=1506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=1506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=1506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}