473,387 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

connection string problem

I'm trying to display an images directly sourced from a SQL Server dbase,
and it would probably work but I can't get the connection string right!

I have tried just LOBSTER and (local), but still no good! In the Data Source
bit, should I be using a forward-slash or is it a double forward-slash?

Computer Name is LOBSTER
DBase is called 'Sandwich Shop Development'
Table is called 'Product'
There is no password on the dbase

Here is my code:

In webform1.aspx.vb, I have this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

If Not Page.IsPostBack Then

BindGrid()

End If

End Sub

Public Sub BindGrid()

' Bind datagrid with dbase

Dim connstr As String = "Integrated Security=SSPI; Initial
Catalog=Sandwich Shop Development; Data Source=LOBSTER\localhost"

Dim cnn As New SqlClient.SqlConnection(connstr)

Dim da As New SqlClient.SqlDataAdapter("select * from Product", cnn)

Dim ds As New DataSet

da.Fill(ds, "Product")

DataGrid1.DataSource() = ds

DataGrid1.DataBind()

End Sub

Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object, ByVal e
As DataGridItemEventArgs)

'ItemDataBound event

Dim img As System.Web.UI.WebControls.Image

If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType
= ListItemType.Item Then

img = CType(e.Item.Cells(5).Controls(5),
System.Web.UI.WebControls.Image)

img.ImageUrl() = "WebForm2.aspx?id=" & e.Item.Cells(5).Text

End If

End Sub

In webform2.aspx.vb, I have this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Webform that returns image data

'Fetch image based on the query string passed

Dim connstr As String = "Integrated Security=SSPI; Initial
Catalog=Sandwich Shop Development; Data Source=LOBSTER\localhost"

Dim cnn As New SqlClient.SqlConnection(connstr)

Dim cmd As New SqlClient.SqlCommand("select * from Product where
ProductId=" & Request.QueryString("id"), cnn)

cnn.Open()

Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader()

dr.Read()

Dim bindata() As Byte = dr.GetValue(5)

Response.BinaryWrite(bindata)

End Sub
Nov 21 '05 #1
3 1475
Anthony,

Goto http://www.connectionstrings.com

I hope that will help you

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Hi,

Try this.

Dim connstr As String = "Integrated Security=SSPI; Initial
Catalog=Sandwich Shop Development;Data Source =(local)"

Ken
-----------------
"Anthony Smales" <ar**@hotmail.com> wrote in message
news:PD********************@karoo.co.uk...
I'm trying to display an images directly sourced from a SQL Server dbase,
and it would probably work but I can't get the connection string right!

I have tried just LOBSTER and (local), but still no good! In the Data Source
bit, should I be using a forward-slash or is it a double forward-slash?

Computer Name is LOBSTER
DBase is called 'Sandwich Shop Development'
Table is called 'Product'
There is no password on the dbase

Here is my code:

In webform1.aspx.vb, I have this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

If Not Page.IsPostBack Then

BindGrid()

End If

End Sub

Public Sub BindGrid()

' Bind datagrid with dbase

Dim connstr As String = "Integrated Security=SSPI; Initial
Catalog=Sandwich Shop Development; Data Source=LOBSTER\localhost"

Dim cnn As New SqlClient.SqlConnection(connstr)

Dim da As New SqlClient.SqlDataAdapter("select * from Product", cnn)

Dim ds As New DataSet

da.Fill(ds, "Product")

DataGrid1.DataSource() = ds

DataGrid1.DataBind()

End Sub

Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object, ByVal e
As DataGridItemEventArgs)

'ItemDataBound event

Dim img As System.Web.UI.WebControls.Image

If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType
= ListItemType.Item Then

img = CType(e.Item.Cells(5).Controls(5),
System.Web.UI.WebControls.Image)

img.ImageUrl() = "WebForm2.aspx?id=" & e.Item.Cells(5).Text

End If

End Sub

In webform2.aspx.vb, I have this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Webform that returns image data

'Fetch image based on the query string passed

Dim connstr As String = "Integrated Security=SSPI; Initial
Catalog=Sandwich Shop Development; Data Source=LOBSTER\localhost"

Dim cnn As New SqlClient.SqlConnection(connstr)

Dim cmd As New SqlClient.SqlCommand("select * from Product where
ProductId=" & Request.QueryString("id"), cnn)

cnn.Open()

Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader()

dr.Read()

Dim bindata() As Byte = dr.GetValue(5)

Response.BinaryWrite(bindata)

End Sub

Nov 21 '05 #3

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uJ**************@TK2MSFTNGP14.phx.gbl...
Hi,

Try this.

Dim connstr As String = "Integrated Security=SSPI; Initial
Catalog=Sandwich Shop Development;Data Source =(local)"

Ken


already tried that one :(
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paul Robinson | last post by:
I am developing a website in ASP that connects to a Sybase database. However, when I try to open a connection to the database the page will not load. The script does not timeout, nor the...
17
by: AMC | last post by:
Hi, I'm using an include file to store the connection string to a database. Whenever I try to reference that string to open a connection in the page that includes the file I get the error 'empy...
0
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem...
4
by: Rahul Anand | last post by:
Getting SQL Exception when trying to implement Connection based Trasaction using SQL Helper class. I am using the follwing function to execute my stored procs: -=-=-=- ExecuteScalar(ByVal...
6
by: Bala Nagarajan | last post by:
Hello, I am using Oracle 9i in my application and facing a problem with the connection string. In the datasource attribute of the connection string i had to specify an entry in "tnsnames.ora"...
14
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review,...
2
by: RyoSaeba | last post by:
Hello, I have a problem with the session state set to Sql Server (AspNet 1.1, Windows Server 2003 on an Application Center cluster, Sql Server 2000 on another server). Sometimes, when many user...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
3
by: Harry Strybos | last post by:
Hi All I have a really strange problem occurring in my application. When I read in the application settings for connection strings the following happens: Here are my connection string settings...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.