473,320 Members | 1,846 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,320 software developers and data experts.

How to edit using data reader

11
I need to make an edit page using data reader.
this is my code..
Expand|Select|Wrap|Line Numbers
  1. Sub Page_Load()
  2.         If Not IsPostBack Then
  3.             Dim conn As SqlConnection
  4.             Dim cmdSQL As SqlCommand
  5.             Dim dataReader As SqlDataReader
  6.             Dim SQL As String
  7.  
  8.             Dim libBookID As Integer = Request.QueryString("lid")
  9.             conn = New SqlConnection("Server=xxx.xxx.xxx.xxx;Database=projectsurveys;Uid=surveygroup;Pwd=XXXXXXXXXX")
  10.             cmdSQL = New SqlCommand("getLibraryBook", conn)
  11.             cmdSQL.CommandType = CommandType.StoredProcedure
  12.             cmdSQL.Parameters.AddWithValue("@LibID", libBookID)
  13.             conn.Open()
  14.             dataReader = cmdSQL.ExecuteReader()
  15.             While dataReader.Read()
  16.                 txtTitle.Text = dataReader("Title")
  17.                 Select Case (dataReader("Category").ToString())
  18.                     Case "Early Childhood"
  19.                         lstMediaType.SelectedIndex = 0
  20.                     Case "School-Aged"
  21.                         lstMediaType.SelectedIndex = 1
  22.                     Case "Adult"
  23.                         lstMediaType.SelectedIndex = 2
  24.                 End Select
  25.                 txtAuthors.Text = dataReader("Author")
  26.                 txtPublisher.Text = dataReader("Publisher")
  27.                 txtCity.Text = dataReader("City")
  28.                 txtYear.Text = dataReader("Year")
  29.                 txtISBN.Text = dataReader("ISBN")
  30.                 Select Case (dataReader("MediaType").ToString())
  31.                     Case "Audio"
  32.                         lstMediaType.SelectedIndex = 0
  33.                     Case "Book"
  34.                         lstMediaType.SelectedIndex = 1
  35.                     Case "Manual"
  36.                         lstMediaType.SelectedIndex = 2
  37.                     Case "Other"
  38.                         lstMediaType.SelectedIndex = 3
  39.                     Case "Periodical"
  40.                         lstMediaType.SelectedIndex = 4
  41.                     Case "Seminar/Conference"
  42.                         lstMediaType.SelectedIndex = 5
  43.                 End Select
  44.                 txtKeywords.Text = dataReader("Keywords")
  45.                 txtComments.Text = dataReader("Comments")
  46.                Select Case (dataReader("CheckedOut"))
  47.                    Case "Available"
  48.                        Status.SelectedIndex = 0
  49.                    Case "Checked Out"
  50.                        Status.SelectedIndex = 1
  51.                End Select
  52.  
  53.             End While
  54.             dataReader.Close()
  55.             conn.Close()
  56.         End If
  57.     End Sub
  58.  
I am getting an error saying "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "

Please help me!!!
Oct 16 '07 #1
2 1486
Plater
7,872 Expert 4TB
I am getting an error saying "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "
Well have you taken care of the settings like it says? To allow remote connections, named pipes, and anything else?

And are you using the write connection string for your database type?
Oct 16 '07 #2
Frinavale
9,735 Expert Mod 8TB
Hi Sacha4,

If you have control of your database server, make sure that it allows your code to access it. Since you're not using Windows Integrated Security to connect to it, please ensure that your database's security is set up to authenticate using SQL authentication as well.


---------------------------------------------------------------------------------------------------------------

In the future, please use place any code you post within [code] tags.
For example, to post a snippet of VB.NET code:
[code=vbnet]
'My Vb.NET code
[/code]

Also, it is not advisable to post your IP and password to your database.
In the future please take measures to protect this very private information. This is for the safety of your computer.

Thanks!
-Moderator/Frinny
Oct 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Junior | last post by:
I keep receiving this "The type or namespace name 'CASsEventHandler' could not be found (are you missing a using directive or an assembly reference?)" message in two particular lines, and I've...
1
by: Stephen | last post by:
I'm having terrible trouble working out where I have gone wrong in my code below. In the data layer I have two methods and i'm basically returning a command and using it and then returning a...
5
by: Wing | last post by:
Hi all, I execute a stored procedure in my C# code, assign the result to the SqlDataReader object and display it with datagrid. the question I like to ask, is possible to edit the datagrid...
1
by: Jack Black | last post by:
Hi, all! I have a populated Reader that I'm binding to a data grid, and I'm trying to figure out how I can edit cells BEFORE binding the reader to the DataGrid. Of the few pieces of sample code...
2
by: Mattyw | last post by:
Hi I have a sqlcommand that returns all the rows in a column and then pass that to a datareader. I am new to VS.Net and so far I can only return the first row in the first column using ...
2
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image....
12
by: Jerry Camel | last post by:
Not sure if this is a good place to post this... I'm writing and ASP.net app using vb .net. I need to interact with a credit card reader. I have one that sits inline with the keyboard. Works...
3
by: Loane Sharp | last post by:
Hi there I use the FileStream object to download a zip file over the internet to my local disk. The file downloads successfully, but when I attempt to unzip it, I'm told that the file is in use...
1
by: cyningeston | last post by:
OS: WinXP Pro, VB/ASP/ADO.NET I'm building a web-based supplier management application. For each supplier we are required by the FDA to track certain documents. I've managed to pull them from...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.