Using Multiple Datareaders With Same Connection?

Jul 14, 2009

I am using datareader to retrieve data. I want to use multiple datareader at a time with same connections. WHen i used it, it gives an error as connection should be closed before using it next time.

View 23 Replies


ADVERTISEMENT

ADO.NET, Datareaders And VB.NET Speed?

Feb 28, 2008

currently writing a standard 3-tier (gui/business layer/data layer) winforms application in Visual Studio 2008.I have a form which has to load around 20 different sets of un-related data when it opens. My data layer returns seperate data readers to the business layer and each routine uses seperate sql connections (it opens them, gets a data reader, and then closes it).Now the problem i have is the speed the data is being retrieved. For a relativly small amount of data (around 100 rows of data combined) it's taking say 10 seconds to retrieve, parse into seperate collections and then paint to screen.My form is using controls from Infragistics and Component One and is quite heavy anyway

View 2 Replies

DB/Reporting :: Using Nested DataReaders?

Apr 3, 2012

I'm working with a database that includes a table called MenuItems. The table is hierarchical, so an item can have child items under it. A record's ParentID corresponds to the ID of the parent record, or the ParentID can be 0 if the item is on the top level.What I'm trying to do is create a VB.Net application to populate a TreeView with the records in my MenuItems table, using the recursive function ListSubMenus in the code below:

Code:
Private Sub ListSubMenus(ByVal ptvnParent As TreeNode, ByVal plngParentID As Long)
Dim strSQL As String

[code].....

View 5 Replies

VS 2005 Why Are DataReaders Read Only Forward Only

Jun 27, 2010

I have been studying about the DataReader in the msdn from a couple of hours and i habe seen that they are using this term:Read only Forward only a lot of times for the DataReader but i cant understand why?Why are DataReaders Read only Forward only?

View 12 Replies

Use Multiple Datareader In Same Connection?

Sep 8, 2009

I am using MySql 5.0. I using Mupliple datareader in same connection i get error message. Is possible to use multiple Datareader in same connection?

I using Mysql Connection is

MySqlConn.ConnectionString = "SERVER=" & gServerName & ";DATABASE=" & DBname & ";user=" & gUserName & ";password=" & gPassword & ";MultipleActiveResultSets=True"
MySqlConn.Open()

View 1 Replies

Use One SQL Connection With Multiple Transactions?

Sep 19, 2011

I have a vb.net web app and I am passing a SQL connection and a transaction to a method which writes a single record to the database.

I would like to start and commit a transaction for each record that is written but using the same sql connection until the loop is done.

One method I saw was utilizing a using statement but it didn't work for me.it runs the first time and gives an error on the second that the transaction has already been commited

Using sqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)

[Code]....

View 2 Replies

How To Use Database Connection Through Multiple Forms

Mar 2, 2010

I'm testing database programming in vb.NET 2008 at the moment and try to find a way to use a database connection in different forms, so e.g. I put the the database-connection-component into one of the forms. I know, I could access it by e.g. form1.databaseconnection.xxx, but is this the best way or can I "put" the connection into something more abstract which all forms know about?

View 2 Replies

VS 2010 .NET Multiple Database Connection?

Dec 15, 2011

is there a function that will allow coders to connect to multiple database? by just changing the connection string and not the variable declaration ...example:connecting to access is something like this

Dim Con As New System.Data.OleDb.OleDbConnection(ConString)

for sql is something like this

Dim Con As New System.Data.SqlClient.SqlConnection(ConString)

is it possible? acctually in vb 6.0 it is possible ...

View 2 Replies

VB 2008 With MsAccess Connection On Multiple Forms?

Aug 6, 2011

I have a VB Solution with a dozen forms trying to implement invoice system.My main form (Say Form1) only has a design to create , Edit or Delete Customers.My form 2 will be opened if Create button is clicked. In my form 2, I have textboxes where user can enter Customer details and click on SAVE. My doubt is here....On clicking this SAVE button in Form 2, I want a INSERT command to happen on the MSAccess's Database table called Customer (which I have already created... this table does not have any records as of now). In my form 1, I added a MSAccess Database with a Connection String. In my Form1's code I have code like this[code]...I got this piece of code from this link [1]: vb.net - sharing mdb access connection among multiple forms/Now, I do not know what more code does this require to INSERT records from my text box into the Customer table's fields.

View 1 Replies

.net - Sharing Mdb Access Connection Among Multiple Forms?

Sep 7, 2010

I'm starting to put in a database into my application, however I'm drawing a blank on how to share a database connection among the dozen or so different forms in my MDI application. I'm assuming this has to do with interfaces or something but I can't find any relevant examples anywhere. Can someone help me out? Ideally what I'd like is when the app is loaded up there is a call to a function in the forms loading area which establishes a single connection to the mdb, that I can then call via any form so I don't always have to open/close connections everytime I need to update the db?

Here's a basic example of the mdb database access code I've got working:

Dim dt As DataTable = New DataTable()
Dim OleDbTran As OleDbTransaction = Nothing
Using connJET As OleDbConnection = New OleDbConnection("connection string here...")

[code]....

View 1 Replies

Managing Multiple Client Socket Connection?

Sep 11, 2011

Am developing a server - client application using the system.net class , that will have more than 5000 simultenous client connection.what is the best way to manage multiple client connection like this?

View 3 Replies

VS 2008 Multiple Connection String Manipulation?

Oct 27, 2011

I am creating an VB 2008 application which uses 2 connections strings in according in which computer is running (my test machine, and the production server). How should i manage the connection string in order not to change manually the connections string which are many inside the code??

I have read that you can read them from an external line, or if you put both connection strings in an external file, according in which machine the program is running can actually the correct string?

View 9 Replies

Make A Simultaneous Connection To Multiple Servers With Threads?

Mar 15, 2010

I want to make a simultaneous connection to multiple servers with threads, only to create a single connection.

Imports System.IO
Imports System.Net.Sockets
Imports System.Text

[Code].....

View 5 Replies

Windows - Close A .NET Application That Is Accessed By Multiple PC On The Same Connection?

Jun 7, 2012

I have an application that I made in VB.NET. I put it in the server on my office and every other user access it via network connection. I only mapped the drive onto their computer and then I cope the shortcut to the application. can I close all the application that is running with a single code? I sometime need to close all the application first before I can do anything with the application (for example, modifying the report etc.). My current method is still the manual one, which is calling everyone to close their application or running all over the place closing the application myself.

View 1 Replies

Asp.net - .NET Framework Data Provider For Oracle Multiple Open Connection

Jan 17, 2012

I have the below mentioned code in a seperate class file for establishing connection and carry out DB transactions. I have an issue where multiple connections being opened which sometime exceed the connection pool. When I stepped through the code I found that there are codes which call ConnectDB() in a loop without calling DisconnectDB(). But I expected that the condition OraConn.State = ConnectionState.Closed should handle the situation. Somehow the condition is always satisfied hence openning another set of connection. Can you suggest where am I going wrong and also what best practice can be adopted here?

[Code]...

The connection is again opened in function updData(). While I understand that it has to be closed correctly but keeping tab on every developer is not possible. Hence I want to control it directly from the connection class by using the same connection but the condition If OraConn.State = ConnectionState.

UPDATE I have put the code in UpdateDB under a Using block and removed call to ConnectDB and DisconnectDB from function like InsertData(...). It seems that the issue has been resolved. But I would like to know in case of exception will the connection remain open? and also OraConn is a public variable defined outside Using block so will it be disposed of by the GC?

[Code]...

View 1 Replies

Assign A My.Settings.Item Connection String To Cmd.Connection Connection String Value?

Aug 25, 2009

How do I assign a My.Settings.Item connection string to cmd.Connection connection string value?

Dim cmd As New SqlCommand()
cmd.Connection = My.Settings.Item("csStaffHoursWorked")
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spSaveDeltekImport"

View 3 Replies

Display Connection Properties Dialog For Connection String Browsing(for Database) In Run Time?

Feb 5, 2010

Is there a way to display the connection properties dialog for connection string browsing(for database) in run time?

As I want the user to be able to connect to various database using the GUI.

View 6 Replies

Error - ExecuteScalar Requires An Open And Available Connection - The Connection's Current State Is Closed

Aug 3, 2011

i have an application. which is executed after every 5 mins. i have an open connection but it gives me the following error:

ExecuteScalar requires an open and available Connection. The connection's current state is closed.

my code is something like this. I have shown where all i am using ExceuteScalar()

Sub Main()
Try
connection.open()
cmd.ExecuteScalar()

[code]....

View 2 Replies

Sql Server - .net Program Dataadapter Connection Closes After Fill But Database Still Shows Connection?

Aug 19, 2010

After running the following sub (VS debugger), I try to detach the database in SSMS, but it shows the connection open still and won't let me detach. If I close program in debugger, the database shows no connections. I check the dataadapter's connection in the finally block and is shows closed. What gives

Private Function ClientMasterDBFiles(ByVal MasterClientDBConnection As String, ByVal DBName As String) As DataTable

[Code]...

View 1 Replies

[2008] Error - Unable To Read Data From The Transport Connection: The Connection Was Closed

Mar 15, 2009

I have a simple scraper. It works on some websites, but on some there is this Error:

Quote:

IOException was unhandled Unable to read data from the transport connection: The connection was closed

It is occuring at "Dim htmlresults As String = Urlcontents.ReadToEnd()".

'Create the HttpWebRequest object
Dim req As HttpWebRequest = WebRequest.Create(URL)
'Set the timeout to 1 second (or 1,000 milliseconds)
req.Timeout = 10000

[code]....

View 2 Replies

Disable The Local Area Connection While Leaving The Wireless Connection Enabled

Jun 21, 2010

I am attempting to write a program that will disable the Local Area Connection while leaving the Wireless connection enabled. My company is using net-books in our stores to demo air-cards and we need to keep them off of the LAN. I'm new to VB and VB.net, and it's been a while since I did any type of programming. I've gathered some code that others have posted in forums and tutorials and I'm working through a tutorial book, but I finally believe that I am stuck.

[Code]...

View 4 Replies

ExecuteNonQuery Requires An Open And Available Connection, The Connection Current Stat Is Close?

Nov 30, 2008

i make a class and when i call on form then that error occurs "ExecuteNonQuery requires an open and available connection, the connection Current stat is close "

Class Code isImports System.Data.SqlClientImports System.DataImports System.StringPublic Class DatabaseKits Dim Cn As New SqlClient.SqlConnection Public Function BuildConnection() As Boolean Try Cn.ConnectionString = "Persist Security Info=False;Integrated Security=True;Trusted_Connection=Yes;database=BizAimsPro2008;server=Server-2k3s" BuildConnection =

[code]....

View 3 Replies

Networkstream Connection Fails & Httpwebrequest Connection Not Reading Fast

May 17, 2012

I am connecting to a data stream that pushes data continuously and when I tried to set up a network stream I just could not connect and kept getting the 'not found' error. I used the httpwebrequest with webrequest.keepalive = true and started to consume the data by reading into a buffer and then appending to a stringbuilder. Once the stringbuilder reaches max size I flush it to a text file. The problem is that I get disconnected from the data stream because I am not reading the data fast enough. I need to keep the connection open and read the data while ensuring data gets stored in text files. If I use method "CONNECT" it does not connect to the stream.

While (True)
webrequest = DirectCast(Net.WebRequest.Create(url), HttpWebRequest)
webrequest.Credentials = New System.Net.NetworkCredential(username, password)
webrequest.Method = "GET"

[code]....

should I increase the buffer size and if so what is the max? that would mean I can read more data at a time and keep up with incoming push. Disparate here.

ACtually also I noticed that it gets stuck on this line

numbytesread = responseStream.Read(bufferread, 0, BUFFER_SIZE)

and then eventually I get disconnected.

View 1 Replies

Networkstream Connection Fails & Httpwebrequest Connection Not Reading Fast Enough

May 17, 2012

I am connecting to a data stream that pushes data continuously and when I tried to set up a network stream I just could not connect and kept getting the 'not found' error. I used the httpwebrequest with webrequest.keepalive = true and started to consume the data by reading into a buffer and then appending to a stringbuilder. Once the stringbuilder reaches max size I flush it to a text file. The problem is that I get disconnected from the data stream because I am not reading the data fast enough. I need to keep the connection open and read the data while ensuring data gets stored in text files.If I use method "CONNECT" it does not connect to the stream.[code]

View 1 Replies

Winforms - .net Connection Entity Framework Connection String Security?

Sep 3, 2011

I understand the possibilities for encrypting a connection string in .net v4. I have a win forms application that will be used by multiple people on different machines. I understand that I need to protect the connection string at time of the app being first run on the target machine. However I am concerned that for a period of time my connection string will be unencrypted. I am looking for advice in how to deploy my app with the connection string already encrypted or encrypted during installation. encrypting the connection string in a secure way?

View 1 Replies

.net - Connection Was Not Closed Connection's Current State Is Open?

Dec 19, 2011

Try If functionmode = "ADD" Then

[Code]...

View 1 Replies

Connection Was Not Closed Connection's Current State Is Open?

Jul 5, 2011

I got this error..The connection was not closed. The connection's current state is open.

This is coding to add data in Ms access in vb...

Imports System.Data.OleDb Public Class Form1

[Code]...

View 5 Replies

Establish A Connection When The App Is Launched And Keep The Connection Open Until The App Is Closed?

May 20, 2010

I'm developing a device app in VB.net that will access a SQL Server database. I need to establish a connection when the app is launched, and keep the connection open until the app is closed. I've done the following:In the Master Module:

Public CNN
As SqlConnection

In the Main menu form load:

CNN =
New SqlConnection(sqlConnString)
CNN.Open()

Then when I want to read from the database:

Dim sqlDR
As SqlDataReader
SQL = "SELECT Name FROM Table"

[code]....

When I run the same code without the global CNN, but rather dim the connection inside the Select function, all works well.

View 6 Replies

Invalid Connection String When Modifying Tableadapter Connection?

Jan 19, 2011

I'm developing an app in vb.net (visual studio 2008). I have a Teradata back-end that will be supporting multiple users in a production environment. I need to use variables in the connection string as the user/pass will be changed every 3 months.

For the gist of the application:

In it's most basic form - I have a search form which works correctly - it pulls results into a listbox and the user then double clicks the list box which will then open a form that is bound via table adapter to the back-end table (Teradata). My connection string is fine everywhere in the application. My problem is using a modified connection string for the "fill" function of the table adapter once the form is opened.

I'm using the code below for the on-load event and keep getting an "invalid connection string" - again, the connection string works fine everywhere else in the app, and the variables etc... are working correctly.

Private Sub adaptertest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DBConnStr As String = "Provider=TDOLEDB;Data Source=TDDEV;Persist Security

[Code].....

View 5 Replies

Mdb Connection - Transfer File Path In Our Connection String

Aug 26, 2009

I'm facing a problem after installation any software setup that has a database in access(mdb file) How to I transfer file path in our connection string.

View 3 Replies







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