connection and get data from SQL

S

S Prom

I made the changes in web.config to use db_app

<%@ Page Language="VB" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient"%>

connectionstring = ConfigurationSettings.AppSettings("db_app")

strQ = "Select field1,field2,field3 From tbldata where field1 ='1'"

objRS = objConn(strQ)

objConn.close()
objConn = nothing

I am just trying to make a connection to the database and getting data.
I know I have the web.config part right, but I just can't get it to
execute the query. I tried searching the groups for a couple of days
already but no success.

So if anyone can help, thanks.
 
C

Cowboy \(Gregory A. Beamer\)

You know you are SO ASP if: :)

Try this:

'Assume these are correct
connectionstring = ConfigurationSettings.AppSettings("db_app")
strQ = "Select field1,field2,field3 From tbldata where field1 ='1'"

Dim conn As New SqlConnection(connectionstring)
Dim cmd As New SqlCommand(strQ, conn)
Dim ds As New DataSet("dataSetNameHere")
Dim da As NewDataAdapter(cmd)

Try
conn.Open()
da.Fill(ds)
Finally
conn.Dispose()
End Try

You can now bind the DataSet (ds) wherever you want.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top