Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

SELECT INTO and Variables

Posted: Jan/22/2011   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:113   Vote Up (0)   Vote Down (0)    

Hi.

I was wondering if I could use SELECT INTO to put my data into variables.

 

 


I'm coding in VB using Visual Web Developer.

Basically, I want to do this:

SELECT data3, data4 INTO variable1, variable 2 FROM table WHERE  data1= textbox1.text, data2 = textbox2.text

I am pulling data based on a selection of name (data1) and date (data2).

 

Thanks!


View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

select,edit field command

  

hi for all i have gridview i added it select command field

i want when it is clicked,the id of the  table displayed in label

and i have update command field but the problem the update

can't update the primary key i want when it is clicked update all the record

included the primary key

thanks


Html.ListBox cannot select multiple items

  

I'm trying to use the ListBox html helper in a simple form.

verhuurPrijzenLst is a simple list that gets put into the ListBox, I think I need "MultiSelectList", but I cannot use it (MVC framework needed)?

I don't know exactly how to do that ( bin folder and @inherits ? )

So it's nice to have a helper at hand, but if you cannot use it properly without using the MVC framework, that is a pity.


   List<SelectListItem> verhuurPrijzenLst = new List<SelectListItem>();
   foreach (string dataLine in verhuurPrijzen) {
        var verhuurPrijslijn = dataLine.Split(delimiterChar)[0].AsDateTime().ToString("dd MMMM") + " - " + dataLine.Split(delimiterChar)[0].AsDateTime().AddDays(7).ToString("dd MMMM") + " ? " + dataLine.Split(delimiterChar)[1] + ",00";
        var selecteer = false;
        if(Request["Huurperiode"] != null)
        {
            if(Request["Huurperiode"].Contains(verhuurPrijslijn))
            {
                selecteer = true;
            }
        }
        verhuurPrijzenLst.Add(new SelectListItem { Text = verhuurPrijslijn, Selected = selecteer });
    }
    @Html.ListBox("Huurperiode",verhuurPrijzenLst,new {size="15", multiple="multiple"});





Session Variables lost in iFrame

  

I have session variable that is created in EditPlaylist.aspx.  Edit.aspx is loading EditPlaylist.aspx in an iframe.

when loading sessions from EditPlaylist.aspx page they are null.
the session was not before I added the  EditPlaylist.aspx to an iFrame.  Is there a workaround for this?
<iframe src="EditPlaylist.aspx" width="100%" height="100%"></iframe>


passing parameters for a SELECT query to another page

  

I have an asp.net site which includes a "search" page that queries an SQL table, then redirects the user to a "results" page where the results of the query are displayed.

The parameters for the query are assembled into a string which is the SELECT statement.

I've been asked to add additional functionality that requires a secondary search which takes place on the "results" page. How can I pass the parameters from the "search" page to the "results" page so that I can access those parameters in the code behind? 

Thanks for any help.

Here's the first page code behind (I inherited most of this from another developer):

using System;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Maine_Innkeeper_Site_2010
{
    public partial class searchtest : System.Web.UI.Page
    {
        private string name = string.Empty;
        private string city = string.Empty;
        private string desc = string.Empty;
        private string propType = string.Empty;
        private string regionStr = string.Empty;
        private List<string> amenities = new List<string>();
        SqlCommand cmd = new SqlCommand();

        //if the form is submitted...
        protected void submit_Click(object sender, EventArgs e)
        {
            if (gatherDataFromForm())
            {
                string sql = buildSQLStatement();
                Session["lodgingSearchSql"] = sql;
                Response.Redirect("lodging-search-output.aspx");
            }
        }

        //if the image map is clicked...
        protected void ImageMapClicked(object sender, ImageMapEventArgs e)
        {
            //establish a variable for the value of the region clicked  
            string Region = e.PostBackValue; 

            //build the query
            bool needAnd = false;
            StringBuilder sb = new StringBuilder();
            sb.Append("SELECT ID, PropertyName, City, Image1, Image2, InnLinkURL, EnhancedListing ");
            sb.Append("FROM members WHERE Region = '" + Region +"' ORDER BY City, PropertyName");
            string sql = sb.ToString();
            Session["lodgingSearchSql"] = sql;
            Response.Redirect("lodging-search-output.aspx"); 
        }

        private bool gatherDataFromForm()
        {
            name = common.scanForSqlAttack(PropertyName.Text);
            city = common.scanForSqlAttack(PropertyCity.Text);
            desc = common.scanForSqlAttack(PropertyDescription.Text);

            try
            {
                propType =
                   common.scanForSqlAttack(PropertyType.SelectedValue).ToUpper();
            }
            catch
            {
                propType = "";
            }
            try
            {
                regionStr = common.scanForSqlAttack(region.SelectedValue);
            }
            catch
            {
                regionStr = "";
            }
            for (int i = 0; i < amenityList.Items.Count; i++)
            {
                if (amenityList.Items[i].Selected)
                    amenities.Add(amenityList.Items[i].Value);
            }
            return true;
        }

        private string buildSQLStatement()
        {
            bool needAnd = false;
            StringBuilder sb = new StringBuilder();
            sb.Append("SELECT ID, PropertyName, City, Image1, Image2, InnLinkURL, EnhancedListing ");
            sb.Append("FROM members WHERE ");
            if (name.Trim() != "")
            {
                //if (ExactName.Checked)
                 //   sb.Append("PropertyName = '" + name.ToUpper() + "'");
                //else 
                sb.Append("PropertyName like '%" + name.ToUpper() + "%'");
                needAnd = true;
            }
            else  // not selected by name, use the other selectors
            {
                if (city.Trim() != "")
                {
                    if (needAnd)
                        sb.Append(" AND ");
                    else needAnd = true;
                    if (ExactCity.Checked)
                        sb.Append("city = '" + city.ToUpper() + "'");
                    else sb.Append("city LIKE '%" + city.ToUpper() + "%'");
                }
                if (regionStr.Trim() != "")
                {
                    if (needAnd)
                        sb.Append(" AND ");
                    else needAnd = true;
                    

How to select population based on district?

  

How to select population based on district?
   Ex table: Country, District, Population, State 


How to use stored procedure for insert,update,delete,select in Entity framework 4 with MVC2

  

hi friends,

i m new bie in the MVC.

i want to know how to call stored procedure in entity framework. how to do code with controller class and with model.

i mean if i want to call  insert,update,select,delete stored procedure for entity framework then what are stps i have to follow.


plz help me if anybody knows!!!!

Thanks



How select child node completely using LinQ?

  

Sample Xml:

string strXml = "<txtLongDescription> <teaser> Based upon the Expert Panel's recommendations, AHRQ has revised and</teaser>";

strXml = strXml + "<strong>Two Comment periods:</strong></txtLongDescription>";

Sample C#: XElement.Parse(strXml).Element("txtLongDescription").Value


Expected Output:<teaser> Based upon the Expert Panel's recommendations, AHRQ has revised and</teaser><strong>Two Comment periods:</strong>

How do I get the above expected output, because the above sample c# code assumes <teaser> as another node doesn't give me child node or child text.




Accessing Member Variables

  

All:

Is there a way to access member variables defined in code from rules defined in the GUI, or do i have to write them out to a node in the data source to access them?

Thanks in advance.

Ed


Problem with Calendar view using Calendar Overlay when i select Exchange as source of Calendar

  

Hello,

i have a problem with Calendar view using Calendar Overlay.

Here i am creating a calender list with type "exchange".

Here is the expected output shown below:

But in my case it is giving the output shown below:

can you please provide some possible solution.


Kancharana

Multi-select Refinement Search Web part

  

Hi Everybody,

i want to create a SharePoint 2010 Search Center with Refinement Panel Web part. but instead of single select keyword, we need to create a multi-select refinement web part. can anybody provide a solution for this ???


 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge