Solved

Store Sessions variables from SQL Query in Code.

Posted on 2014-03-27
2
672 Views
Last Modified: 2014-03-27
I want to pass an ID to a sql query.

The results of the query I want to put in session variables.

I'd like to do this all in the vb code.

So, to summerise, I want to execute a SQL qury when I click on a button or a gridview selected change event.   That then feeds an ID into a SQL query and the returned results are all stored in session variables.   All in the code.  

Thanks
0
Comment
Question by:edjones1
  • 2
2 Comments
 

Accepted Solution

by:
edjones1 earned 0 total points
ID: 39959358
So I've worked out how to put the results into a gridview but what I really want is to add the results to session variables display in a gridview.

 Dim strConnString As String = ConfigurationManager.ConnectionStrings("CFLoanQuoteConnectionString").ConnectionString

            Dim sqlConnection1 As New SqlConnection(strConnString)

            Dim query As String
            Dim SqlCommand As SqlCommand
            Dim reader As SqlDataReader

            Dim adapter As New SqlDataAdapter()
            'Open the connection to db
            sqlConnection1.Open()

            'Generating the query to fetch the contact details
            query = "SELECT * FROM All"

            SqlCommand = New SqlCommand(query, sqlConnection1)
            adapter.SelectCommand = New SqlCommand(query, sqlConnection1)
            'execute the query
            reader = SqlCommand.ExecuteReader()
            'Assign the results 
            GridView1.DataSource = reader

            'Bind the data
            GridView1.DataBind()

Open in new window

0
 

Author Closing Comment

by:edjones1
ID: 39960390
worked it out myself
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question