Dropdownlist: Database Connections Problems At EditItemTemplate

Apr 25, 2006

Hello,

I'm attempting to generate a dropdownlist by binding it to a database table.  My screen has a view of the records plus a footer for inserting new records.  I want to populate a drop down list of items from the database on both FooterTemplate and EditItemTemplate.  I can successfully create the list on FooterTemplate (the insert new record fields).  Here, I have no problems with my database connections.

On page load, if I hit 'Edit', it gives me this error:

There is already an open DataReader associated with this Connection which must be closed first.

I tried closing the datareader and I get an error: Invalid attempt to Read when reader is closed.

Here's the snippet of code:

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

LoadDataFromDB()

If Not IsPostBack Then

DataBindGrid()

End If

End Sub

Sub LoadDataFromDB()

Dim strSQLStmnt As String

Dim cmdDefaults As SqlCommand

' Create new command object passing it our SQL query

' and telling it which connection to use.

strSQLStmnt = "SELECT tblTemplates.TemplateID, tblTemplates.Description, " _

& "tblTemplates.Tuition, tblTemplates.Books, tblTemplates.TrainingTable, tblTemplates.Housing, " _

& "tblResidency.ResidencyType, tblCategory.Type, tblCategory.Description AS CategoryDesc, " _

& "tblScholarship.ScholarshipType FROM tblTemplates INNER JOIN tblResidency ON tblTemplates.ResidencyID = " _

& "tblResidency.ResidencyID INNER JOIN tblScholarship ON tblTemplates.ScholarshipID = tblScholarship.ScholarshipID " _

& "INNER JOIN tblCategory ON tblTemplates.CategoryID = tblCategory.CategoryID"

cmdDefaults = New SqlCommand(strSQLStmnt, conDefaults)

' Open the connection, execute the command, and close the connection.

conDefaults.Open()

rdrDefaults = cmdDefaults.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

DefaultsDataGrid.ShowFooter = True

End Sub

Sub DataBindGrid()

DefaultsDataGrid.DataSource = rdrDefaults

DefaultsDataGrid.DataBind()

End Sub

Function BindResidency() As DataSet

'Populate the ddlDataSet

Const strSQLDDL As String = _

"SELECT Distinct ResidencyID, ResidencyType FROM tblResidency"

Dim myDataAdapter As SqlDataAdapter = New _

SqlDataAdapter(strSQLDDL, conDefaults)

myDataAdapter.Fill(ddlDataSet)

Return ddlDataSet

End Function

And the asp.net:

      <asp:TemplateColumn HeaderText="Residency">
       <ItemTemplate>
        <%# Container.DataItem("ResidencyType") %>
       </ItemTemplate>
       <FooterTemplate>
        <asp:DropDownList id="add_residency" runat="server" Width="178px" DataSource="<%# BindResidency() %>" DataTextField="ResidencyType" DataValueField="ResidencyID">
        </asp:DropDownList>
       </FooterTemplate>
       <EditItemTemplate>
        <asp:DropDownList id="edit_residency" runat="server" Width="178px" DataSource="<%# BindResidency() %>"  DataTextField="ResidencyType" DataValueField="ResidencyID">
        </asp:DropDownList>
       </EditItemTemplate>
      </asp:TemplateColumn>

Any help would be appreciated!

Thanks,

Curtis

View 2 Replies


ADVERTISEMENT

Get Info From Database With Dropdownlist

Dec 19, 2003

How do you get info from an SQL database to be displayed on a dropdownlist?

View 2 Replies View Related

Dropdownlist Database Search

Mar 19, 2008

Hi all.

I have a huge problem that ive been sitting with for awhile.

I have a web page with 4 dropdownlist boxes on it

Gender:
Race:
Field:
Location:

Now a user can search a SQL db from selecting values from these 4 dropdownlist boxes which are equal to values in the db obviously.

when they have done that and pressed submit a Gridview is populated with the people corresponding details and the user is able to view each row seperately.

Now the problem i am having is that when i havent used all 4 selections for eg

Gender: null (no value selected)
Race: Black
Field: Accounting
Location: Los Angeles

then no information is returned from the db in the gridview.
im using a sqldatasource to populate the gridview and here is the query string that i am using :


Code:

sql
SELECT [title], [gender], [initials], [name], [surname], [birthdate], [postaladdress], [suburb], [city], [zipcode], [criminalrecord], [drivers], [maritalstatus], [dependants], [citizenship], [province], [contactref], [hometel], [cell], [jobtitle], [relocate], [emmigrate], [email], [worktel], [enddate], [startdate], [FIELD], [education], [company], [positionheld], [jobdescription], [contactperson], [contacttel], [startdate2], [contactperson3], [jobdescription3], [positionheld3], [company3], [enddate3], [startdate3], [contacttel3], [other] FROM [cvinformation] WHERE (([race] = CASE WHEN @race IS NOT NULL THEN @race ELSE [race] END) AND ([province] = CASE WHEN @province IS NOT NULL THEN @province ELSE [province] END) AND ([education] = CASE WHEN @education IS NOT NULL THEN @education ELSE [education] END))



what i want to do is whether the user doesnt choose any selection and leaves the choice null that ALL the information in the table of the db be shown and even if they only choose 2 values and leave the others null then it still brings back the information from the criteria chosen..

Is this possible.?

View 8 Replies View Related

Binding A Database Records To A Dropdownlist

Nov 24, 2006

Hey I just wanted to know if anyone could tell me how to bind values from a database to a dropdownlist?

View 2 Replies View Related

Search For Database Using Textbox And Dropdownlist

Nov 28, 2006

hello..i need your help to provide me the idea and code how to view the data from database based on search criteria from user's input?the user's may fill up textbox and choose a criteria from dropdownlist...i am so no idea how to code it since i am fairly new in asp.net
 

View 5 Replies View Related

Dropdownlist Retrieve Data From Sql Database

Feb 13, 2008

i have 2 dropdownlist which is  ddlCategory and ddlItem.i want<<< a)both ddl get data from sql db.b)view the data in gridview.   i need code in vb.net to retrieve and post.tq  

View 1 Replies View Related

Dropdownlist Resetting On Post Back, ??SQL 2005 Express Database Problem

Apr 21, 2008

Hi all,
I am trying to write a web page connected to an sql database of my MP3 files.  I have a dropdown list box that populates with the artist,  this hopefully being used to filter results into a datagrid.  However,  i am having a problem with the ddlb box repopulating on post back,  i trawled the news groups and coded the population of the ddlb within an "if not page.postback" statement but to no avail.  If i connect the ddlb to another sql database i have,  the page reloads with the selctedvalue retained.  So the theory is now that it is the SQL database,  (is this a limitation of SQL express?) and i am having troubleshooting this.  Here is the SQL of the databse:
USE [mp3]GO/****** Object:  Table [dbo].[Table_1]    Script Date: 04/21/2008 20:40:21 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Table_1]([Title] [nvarchar](50) NOT NULL,[Artist] [nvarchar](50) NULL,[Album] [nvarchar](50) NULL,[Year] [nvarchar](25) NULL,[Comment] [nvarchar](500) NULL,[TrackNumber] [nvarchar](10) NULL,[path] [nvarchar](300) NOT NULL,[genre] [nvarchar](25) NULL,[id] [int] IDENTITY(1,1) NOT NULL,CONSTRAINT [PK_Table_1_1] PRIMARY KEY CLUSTERED ([id] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY]
Any help much appreciated.
 
Cheers
 
Billy

View 17 Replies View Related

Database Create ODBC Connections To Access Database Directly And Update Data?

Sep 10, 2012

We have a SQL database that uses Active Directory with Windows Authentication. Can users that are members of the Active Directory group that has read/write access to the SQL database create ODBC connections to access the database directly and update the data? They dont have individual logins on the server. They are only members of the Active Directory group that has a login?

View 1 Replies View Related

Database Connections

May 25, 2006

Hi all,

I am fairly new to mobile development and im trying to write a simple application that can read, write from a SQL Server Mobile Database and load data into a list view. The problem im having is trying to find examples on how to do this and i cant seem to get many of the ones i find to work properly. Im still use to recordsets and adodb and if anyone has any examples on how to do this that would be great.

Also, would it possible if someone could explain this code to me as well

 Dim conn As SqlCeConnection = Nothing
Dim cmd As SqlCeCommand = Nothing
Dim rdr As SqlCeDataReader = Nothing

Try
' Open the connection and create a SQL command
'
conn = New SqlCeConnection("Data Source = AdventureWorks.sdf")
conn.Open()

cmd = New SqlCeCommand("SELECT * FROM DimEmployee", conn)

rdr = cmd.ExecuteReader()

' Iterate through the results
'
While rdr.Read()
Dim employeeID As Integer = rdr.GetInt32(0) ' or: rdr["EmployeeKey"];
Dim lastName As String = rdr.GetString(5) ' or: rdr["FirstName"];
End While

' Always dispose data readers and commands as soon as practicable
'
rdr.Close()
cmd.Dispose()
Finally
' Close the connection when no longer needed
'
conn.Close()
End Try


Thanks

 

byeadon

View 1 Replies View Related

Enquiry Regarding Database Connections

May 19, 2007

Hi to all,
I was visting one hosting company website and was reading there hosting plans. One line I got there (Maximum number of 50 simultaneous connections are allowed per user/DataBase.). What is the meaning of this line?
Big Thanks!
Harsh 

View 2 Replies View Related

Database Connections Using Facebook As An Example

Feb 20, 2008

I'm trying to work out how facebook displays so much information easily. Each time you visit your profile a load of new info is shown. Is each piece of info, which is stored in different table, gathered right there and then? If so, isn't that a helluva lot of connections? I'm trying to implement something into my website where it records history, a it like on facebook when it says "Steve has written on Paul's wall" the names are clickable. Has the information been stored like:
 
Name1ID ActionID Name2ID23432        56          32432
 
If so, wouldn't 3 connections be needed? 2 to retrieve the names and 1 for the action? It would be easier to store the info as "Steve has written on Paul's Wall" in 1 field, but it wouldn't be dynamic. And if the page shows a lot of information like that, it's hundreds of conections on just 1 viewing.  I'm still learning and am also wondering how many connections per page would take up a lot of resources?
 
Thanks

View 1 Replies View Related

MSDE Database Connections

Nov 13, 2003

I'm using Visual Studio.Net enviroment, i have SQL desktop Engine installed and everything is working great. I have a problem that whenever i create a new database connections i can NOT delete it. I know that i have to select the node containing the connection and then press the DEL Key, but it seems that the delete option is not valid!

Any Suggestion?

View 3 Replies View Related

2 Database Connections For Redundancy.

Sep 21, 2005

Hey Guys,We have a merge replication on 2 MsSQL servers and wondering if its possible to allow the 2 connection strings in our application?So if SQL Server 1 doesnt responed, then the other one will take over.we currently have this in our global.asax:Public Shared dbConnString as String = "Server=xxxx;Initial Catalog=xxxx;User Id=xxxx;Password=xxxx;" So is it possible to change this to look up the first server and then connect to a second server if needed?Thank you for any advice at all.

View 3 Replies View Related

Remote Database Connections With 6.5

Apr 11, 2001

I have a need to connect to a remote (i.e. database on the clients site) SQL Server database from a live application. It is relatively easy under Oracle, but I havent tried to do to an SQL Server. Has anyone done this? The remote SQL Server database in question is 6.5
You can set up odbc connections to remote clients (99% sure on this) so you could go this way. You can also connect directly to a sql box through an IP address in sql7, but I am not too sure how it is with 6.5.

View 1 Replies View Related

Number Of Connections To A Database

Jan 5, 2004

Is there any way to know the number of current connections to an SQL Server Database? Also how can one change the max pool size (for the number of connections allowed to the database)?

Thanks.

View 1 Replies View Related

View Connections To Database...

Sep 25, 2007

Ill make this question simple....

In Access you knew someone was in a database if there was a LDB file.
that LDB file would tell you the "computer name" of who had the connection.

In SQL Express 2005....how can you tell that information?

Thanks in Advance.

View 3 Replies View Related

Dropping Connections To Restore Database

Aug 3, 2000

Hello all,

I need to restore my database and I keep getting a database in use error. Can someone tell me the easiest way to drop all connections to a database and open it exclusively?

Also, I'm not sure where this connection is coming from, there is another database on the same machine that has user connected, can these connections be the problem?

Thanks

Kevin Kraus

View 3 Replies View Related

Database Setup/ Number Of Connections

Jul 15, 1999

I am new to SQL Server 7 and am not sure how to handle setting up/importing FoxPro databases. The consultants that setup the database before me have combined all of the FoxPro databases into one big database in SQL server. The reasoning was that for user applications to have access to different databases in SQL they would need a connection for each database they are using, so if all the data is put into one database then the user would only have one database connection instead of 6 or 7.

Does this make sense to anyone? Someone else thought that this might have been true is SQL Server 6.5 but not in SQL Server 7.0.
Any help will be appreciated.

Mike

View 1 Replies View Related

Active Database Connections SQL Express, How Many

Jun 12, 2006

How can I determine if everyone has logged off of the SQL Express database, ie, no one else is connected.

I need to clean up some files that are generated in my code, but I only want to do that when everyone has logged off the database?

In MS Access, I could try to re-open the MDB file exclusively.

Is there a connection number etc?



View 3 Replies View Related

Kill Just Connections To A Table Instead Of Database ?

Mar 12, 2008

Is it possible to kill just connections to a table instead of database ?

Is it possibe to stop all new connections to a table ?

View 5 Replies View Related

Preventing ODBC Connections To A SQL Database

Oct 4, 2007

I have a user AD account SOPUSJSmith for example. I have given this account security admin at the SQL Server level and dbo at the database level. Is there any way to prevent them from using ODBC to pull data into an Access DB or an Excel spreadsheet?

Thanks in Advance - SOX is killing me!

View 4 Replies View Related

Local Host Not Running Database Connections

May 6, 2008

hi my local host cannot open the connection to my database, whilst testing with vwd seems to be able to do this? other server side functions work (response.write("hello world"))
in my iis the version of .net it says its running reads: 2.0.50727, though when i go to add / remove programmes i have 3.5 there? maybe its nothing to do with .net versions?
thanks in advance for your help
 pete

View 5 Replies View Related

Mulitple Database Connections Vs Single Connection?

Apr 16, 2008

I have a DLL that acts as an interface between the application and the database. So you create a new instance to the database via:

MyDatabaseClass db = new MyDatabaseClass()

Each instance of the class creates a new connection to the database.

So if I were to have the following, then 4 connections would be made.

MyDatabaseClass db1 = new MyDatabaseClass()
MyDatabaseClass db2 = new MyDatabaseClass()
MyDatabaseClass db3 = new MyDatabaseClass()
MyDatabaseClass db4 = new MyDatabaseClass()


My question is...What if instead of creating new connections upon each instantiation, I re-use the same connection through a "ConnectionManager" class. In this way, the above code will only create 1 connection instead of 4.

What do you guys think about each approach? Obviously the 2nd approach makes sense for non-web applications, but what about websites? Would that just cause that single connection to be overloaded??

Thanks for any insights.

View 4 Replies View Related

Close All Existing Connections And Processes To A Database

Jun 4, 2007

Dear all



I created this trigger on a table that i think failed while execution. I tried to modify it and run it again but it seems that i cant do that. If i try and delete the database i also cant - saying that it is still in use. But i am not using it and ther are no other users connected to it. I think the trigger has probably hit a loop and that is holding the link.



To close that i know that a solution would be to restart the SQL server instance but that would be a bit hard since the SQL server where my test database resides is a production server and has few other databases that are important and few users use them.



Is there any way through a SQL statement that there can be forced a delete? Or force close all the connections? Or force close all the processes without actually restarting the SQL server instance.



I have tried all options that were offered on some other forums like forcing it to a single user but even that operation can not be performed saying that the database is still in use.



Thank you so much for all your help and time.



Sincerely

Dan

View 1 Replies View Related

How To Access Remote Connections For A Local Database?

May 5, 2008



Hi 2 All,

I have installed MS SQL 2005 in my system. I have created one database in my server. When iam running my application with this connections it is working fine in my local system. When i uploaded the database to some where dataserver, Iam not getting the connectins due to no remote access .

Some body suggested that to start the SQL browser in the SQL Server Configuration Manager.

I go there n tried to start the service when i put the service properties to Automatic or Manual i am getting the error message that is saying that the service is disabled cannot start automatically.

What could be the wrong?

Please suggest me.
Thanks and regards,

View 3 Replies View Related

Prevent SQL Connections During Database Schema Upgrade

Mar 21, 2007

Hello,

We utilise SQL scripts, executed via sqlcmd.exe, to upgrade the schema and common data of our database(s) when we deploy new versions of our software to a production site. At the moment we simply wait until after hours to do the upgrade and ask nicely for all users to not use the system for a while.

Obviously, asking nicely doesn't always work, and there is also the issue of scheduled server tasks and web services / web sites that operate against the database 24/7.

What are our options for putting the entire server (or preferrably just one database) into a semi-offline state so that users and services cannot connect to it while our script connects and performs the upgrade? I imagine there may be several approaches each with their own pros and cons.

If you could point me in the right direction or perhaps mention what strategy has worked for you, it would be greatly appreciated. We perform these upgrades from hundreds of kilometers away via VPNs and Remote Desktop so we can't just unplug the network cable :).

Thank you.

Regards,
- Jason

View 4 Replies View Related

What Permissions Are Needed To Drop All Connections On A Database?

Oct 6, 2006

I'm looking for the correct permissions to grant a user the ability to be able to drop all connections on a database.

The following code throws an exception:

Dim srv As New Server(SqlServerName)

If srv.Databases.Contains(siDBName) Then
srv.KillAllProcesses(siDBName) '== the srv.KillDatabase will not work here, we must kill the processes first
Dim db As Database = srv.Databases(siDBName)
db.Drop()
End If

Throws the Exception:
Microsoft.SqlServer.Management.Smo.FailedOperationException:
Drop all active database connections failed for Server 'xxxx'.
The user does not have permission to perform this action.

This code DOES NOT throw an exception when run as an Administrator.
Any Ideas?

View 4 Replies View Related

SQL Server 2008 :: Finding Database Connections Not Visible

Jul 15, 2015

I need to find a way to identify SPIDS where queries are connected to certain databases using the 4 dot notation instead of actually being connected to the database in question.

For instance, I connect and my default database is MASTER. In MASTER, instead of typing USE MyDb ahead of my query, I just type my query as:

SELECT Col1, Col2
FROM MyDB.dbo.MyTable

The above is the simple scenario. We usually have queries connecting 3 or 4 user dbs together. So database1 might have a query pointing to database2. What I need is a way to identify the SPIDS that are connecting to database2 despite being in database1.

View 4 Replies View Related

How To Allow Remote Connections To SQL Server 2005 Express Database

Feb 27, 2006

I've developed an asp.net 2.0 web app with vs 2005 and am using a SQL Server 2005 Express database. The app works fine locally, but after uploading to the remote web server the following error occures:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

How do I go about granting remote connections to SQL Server Express?

Does the web server have to have SQL Server Express installed in order to run apps that utilize SQL Server 2005 Express databases?

Do I grant access locally on my machine or do I have to be on the web server to grant remote connections?

I've been using .net 1.1 with access databases for the past couple of years, so this is all new to me.

Thanks.

View 27 Replies View Related

SQL Security :: Enable Encrypted Connections To Database Engine?

Nov 2, 2015

The option:

SQL Server Configuration Manager>SQL Server Network Configuration>Protocol for SQL_xxx (right click)>Properties, we can see two Tabs:

Tab 1: Flags
Tab 2: Certificate

If I set the value of Hide Instance= Yes, does "Force Enctyption", need to be set YES as well? 

Or Force Enctyption has to be enabled in order to hide instance?

What is the recommend settings?

[URL]

View 3 Replies View Related

Manual Creation Of Aspnet Database Fails Does Not Allow Remote Connections

Mar 28, 2007

What do I have to do to get this to work? 
 
C:>aspnet_regsql.exe -A m -E
Start adding the following features:Membership
...............An error has occurred. Details of the exception: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 thedefault settings SQL Server does not allow remote connections. (provider: NamedPipes Provider, error: 40 - Could not open a connection to SQL Server)
Unable to connect to SQL Server database.

View 3 Replies View Related

SQL 2012 :: Close ALL Connections To Particular Database Engine In Management Studio?

Jul 14, 2015

In SQL Server Management Studio, it is possible to do the following:

a) In Object Explorer, connect to a particular SQL Server Database Engine, let's call it X.
b) Use that connection to generate many SQL queries, connected to X, in the right-hand pane.
c) In Object Explorer, connect to a particular SQL Server Database Engine, let's call it Y.
d) Use that connection to generate many SQL queries, connected to Y, in the right-hand pane.
e) Close the connection to X, which was created in step (a), from within Object Explorer.

In the right-hand pane, I am now left with a bunch of queries connected to X, and a similar bunch of queries connected to Y. Any quick way to shut all the queries connected to X, but none of the queries connected to Y?

This question can assume real practical importance if server X is a Live Production Server, and server Y is a Test Server, and my next job of the day is to run a change script against server Y....

I have looked for an option in Management Studio to "Close all queries connected to Server X", but haven't found one.

View 6 Replies View Related

Database Mirroring, Client Connections All ODBC So What Methods Are Recommended?

Jun 5, 2006

As stated in the subject I have a situation where if database mirroring is employed for either manual or automatic failover, all the client (including web connections) connections use ODBC not ADO, or OLEDB etc... so what methods are recommended? Client side redirect is not available so I could not employe the "Data Source =A; Failover Partner=B..." option.

Right now the method employed (pre database mirroring and basically employing log shipping on SQL 2000) is to have a DNS alias for the ODBC connection so that if the server were to change in a failover situation the DNS record would have to be altered, so that all the client connections would not have to be reconfigured.

Regards,

Dominic Baines

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved