Solved

Store Sessions variables from SQL Query in Code.

Posted on 2014-03-27
2
663 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now