VS 2008 - DataReader In Loop Through Text File

Apr 28, 2011

I've wrote a program designed to loop through a text file containing email addresses and unsubscribe said email addresses in our CRM system. I'm having a problem with the following code...

Do While obj_filereader2.Peek() <> -1
strcuremail = obj_filereader2.ReadLine()
Dim dbqCustNo As String = "SQL CODE HERE - SELECT CUSTOMER NUMBER"
Dim exeCustNo As New SqlCommand()
Dim SQLdr As SqlDataReader
exeCustNo.Connection = ConnStr
[Code] ......

The program is falling over when trying to execute the update commands during the datareader loop, with the fabled 'There is already an open DataReader associated with this Command...' error. This program has evolved as I've found problems/better ways of working, so it might be a case of myself just not using the DataAdapter right - I'm guessing I should be using a function of the open DataReader rather than the ExecuteNonQuery command.

View 2 Replies


ADVERTISEMENT

VS 2008 Use Two Datareader In One Loop?

Feb 7, 2010

I m trying to use two datareader in same loop but its not working. Here is the error and code below Error line: DR1 = MyCommand.ExecuteReader()Error message: There is already an open DataReader associated with this Command which must be closed first.

[Code]...

View 2 Replies

VS 2008 - DataReader While Loop (Hang After Few Minutes)

Sep 9, 2009

How come my datareader looping at the while loop line it become totally no response and without error eventhough I got use the try catch error catching... it only will hang on after few minute... after few loop. Is it the data reader got time out limit?? If exceed the limit it will no response..? Inside my while loop it do a lot of transaction and each transaction also take quite long time... it will affect?

myCommand = New MySqlCommand("SELECT * FROM stk_cus_inv_hd WHERE DocType=?DocType;", conn1)
myCommand.Parameters.AddWithValue("?DocType", "CS")
myCommand.CommandTimeout = 99999
myReader = myCommand.ExecuteReader
While myreader.read <<---- it jam at here and totally no response my coding... but my interface is clickable...
my lot of work here...
End While

View 11 Replies

How To Loop A DataReader

Mar 18, 2009

If my Select statement finds data that matches the criteria, how do I get myReader (DataReader) to read each record when there are more then one record found?

Dim myReader As MySql.Data.MySqlClient.MySqlDataReader
myReader = myCommand.ExecuteReader()
If myReader.Read() Then

[code]....

View 5 Replies

ExecuteNonQuery Within The Loop Of A Datareader?

Nov 19, 2011

can i do ( ExecuteNonQuery within the loop of a datareader ) in vb.net please help me with example

View 3 Replies

Forms :: Autocomplete Sequence Using DataReader Loop

May 20, 2009

We're using the Autocomplete functionality for some textboxes. We populate the AutoCompleteCustomSource with data from a database query using a datareader loop. The data in the query is sorted by 'recently used', the most recently used entries are at the top.

Let's say the sequence op the AutoCompleteCustomSource is
'AM1900'
'AF2000'
'AD1950'

After typing an 'A' in the textbox, I would expect the Suggested (or Appended) value to be 'AM1900'. The suggested value however is always the first item from an alphabetically sorted
AutoCompleteCustomSource list (i.e. 'AD1950')

View 2 Replies

VS 2010 : Create Multi-dimensional Array From Datareader From Datareader?

Feb 20, 2012

I have an SQL statement like:

SELECT FNAME, LNAME, CITY from EMPLOYEE

How do I create a multi-dimensional array from a datareader which should store values like:

John, Doe, LA
Mike, Johnson, PASADENA
Freddy, Kruger, Long Beach

View 3 Replies

Loop Through Text File?

Feb 14, 2011

I sometimes use text files to save application data to as I have just found it easy and I just use streamreader/writer to read/write values like so[code]...

View 2 Replies

Loop Through A Directory And For Ever Text File

Feb 8, 2011

I am trying to loop through a directory and for ever text file that I find, convert the encoding to UTF-8 Fromat.

View 2 Replies

Read And Loop Through Text File?

Jun 11, 2010

I am writing a VB.NET program and I'm trying to accomplish the following:
Read and loop through a text file line by line
Show the event of the loop on a textbox or label until a button is pressed
The loop will then stop on any number that happened to be at the loop event and when a button is pressed again the loop will continue.

Code
Imports System.IO
Public Class Form1
'Dim nFileNum As Integer = FreeFile() ' Get a free file number
Dim strFileName As String = "C:scb.txt"
[Code] .....

I'm able to read the text file but my label will only loop if I hit the start button. It goes to the next line, but I want it to continue to loop through the entire file until I hit a button telling it to stop.

View 2 Replies

Reading A Text File And Using A For Loop

Sep 16, 2010

I'm trying to create a program to read a file and create a table. Public Class Form1

[Code]....

View 8 Replies

VS 2010 Writing To A Text File Using A Loop

Feb 26, 2012

basically what I am trying to do is perform a loop that will write the input from an inputbox into the .txt file. My loop doesnt seem to be working,

[Code]...

View 10 Replies

Working With Info From A Text Box And Combo Box With A Datareader?

Apr 7, 2011

I have a data reader pulling in some data from an access database and im trying to get it to add some values to an existing textbox when an item is select, and when another item is selected changing the value.

here is my code

Private Sub FlipsMainItemComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FlipsMainItemComboBox.SelectedIndexChanged, FlipsMainItemComboBox.SelectedIndexChanged
burgerinfoconnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & Application.StartupPath & "ProjectDatabase.accdb")

[code]....

View 3 Replies

Creating A Loop In StringBuilder To Alter A Text File

Jul 2, 2010

I would be grateful with some help with reading a text file into a Richtext box. The code I have at present appends the first line of text as I want it but the rest of the lines of text do not alter. I need a loop to read to the end of file and display in Richtext box. the code i have at present is this:-

[Code]...

View 2 Replies

Loop : Just Reading And Printing The First Line Of A Text File?

Apr 9, 2010

I have a problem with a loop that I'm writing where it is just reading and printing the first line of a text file.

ofdFile.Title = "Choose file to read"
If ofdFile.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
sr = New StreamReader(ofdFile.FileName)
End If

[code]....

Do i have the .peek set up wrong where its only doing the first line?

View 1 Replies

Loop Through Datatable And Output Results To A Text File?

Feb 3, 2011

I have a data table that has thousands of entries. The table has employee production information: YearMonth, Employee ID, Pages worked and Jobtypes (e,k,o and r). I need to calculate a sum of each jobtype and a sum of pages worked for each jobtype, for each individual employee. I am pulling this data from an Access database and so unfortunately I am unable to use LINQ.[code]...

View 4 Replies

VS 2008 - Read Text File - When Click Button Add Text From Combobox Is Added To Text File

Jan 4, 2010

I have one combobox, two buttons (Add and View) and listbox. When I click button Add text from combobox is added to text file. This is code for Add button:

[Code]...

View 7 Replies

VS 2008 Loop A Textboxs Text?

Jan 31, 2010

I'm loading a text file into my textbox via stream reader however when I view this in notepad I see these things in it, then on my form the convert to new lines, how can I remove them?

View 16 Replies

.net - Loop Thorugh A Folder And Read Each Text File Into A String?

Jan 20, 2012

I have a folder that contains about 100 txt files with information in each file.I'm trying to figure out how to loop through each file in the folder, and add the text to a string.I've pulled this off MSDN's site, but it doesn't seem to read "each" file but just one.

Dim path As String = "c: empMyTest.txt"
' This text is added only once to the file.
If File.Exists(path) = False Then

[code].....

View 1 Replies

Datareader Reading From CSV File?

Oct 21, 2011

I try to create a funtion to return a datareader from CSV file as below but got a error said that

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified(at cn.open())

Public Shared Function GetCSVAsDataReader(ByVal csvPath As String) As Odbc.OdbcDataReader
Dim fi As New FileInfo(csvPath)

[Code]....

View 1 Replies

How To Convert CSV File To Datareader

Oct 20, 2011

How to convert CSV file to datareader?I google it but only find out how to convert datareader to CSV file.

View 3 Replies

Datareader - Error - "there Is A Datareader Associate With This Connection That Need To Be Closed"

Aug 17, 2009

I have a problem with my project. here is the problem:

My code for login is as follows:

dim conn as SqlConnection = New SqlConnection("Data Source.................)
dim cmd as SqlCommand = New SqlCommand("Loguser",conn)
cmd.CammandType = CommandType.StoredProcedure

[CODE]...

Now the error i get is that "there is a datareader associate with this connection that need to be closed"

View 4 Replies

VS 2008 Using A DataReader

Jan 27, 2010

I am working on a project which requires me to connect to a MySQL database. From there I query the database and need to do work on the returned values.

I can query the database just fine. However, now I need to do work on the results. The two columns returned are user_name and user_password. The rows are the user accounts. I would like to take my query results and put each column into its own arrary().

[code..]

Instead of writing the results to the console, I would like to write each column to an individual array. Is there an easier way to accomplish this task? Or, what is the code I must place within the loop to do this.

View 3 Replies

Stop And Starts A Running Loop Of Number On A Text File Or Database In Visual Basic?

Aug 25, 2011

I need a small app that randomly shuffles a set of preloaded numbers. The shuffling will be visible on the screen and goes on continuously (looping) until a key is pressed and as soon as that happens it will show the winning number.Am using visual basics 2008 to develop the application but my problem is when i start the app and hit a key it will loop through my numbers on the text file and it will also display the event but if i hit a key to stop it will not stop..I was workin on the app but my problem is how to stop the loop and resume on the with a keypress. below is the app codes.

Dim Running As Boolean = False
Sub ReadAccounts()
Dim arr As New ArrayList
arr.Add("1366-665885-666-22650")[code]....

View 1 Replies

VS 2008 Datareader SQL Express?

Oct 15, 2010

I am doing the basic reading form one table,.it is opening the connection,no problems.i got 5 rows in Categories table with two columns .i got some data as well.using datareader i am trying to read the data.It is not going into while loop

[Code]...

View 5 Replies

[2008] Use The Treeview To Display The Text Of A Rtf (rich Text File) File When An Specific Node If Clicked?

Aug 30, 2009

Hi, i'm trying to use the treeview to display the text of a rtf (rich text file) file when an specific node if clicked.HomeOMGWOOTFor example, if i pick OMG, i want the text of lol.rtf to be displayed on a richtextbox. But somehow i just can't manage to get it... I know to import the text of a .txt file to a textbox, but using the treeview makes it more complicated.This is the code im using right now:

Private Sub TreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
Select Case e.Node.Index
Case 0

[code]....

Another thing is, that i can't import the *.rtf text into a richtextbox and i don't know why.

View 5 Replies

VS 2008 Check For File On Web And Also Exit A Loop?

May 12, 2009

How would i check to see if a file exits on a website before attempting to download it?Also in my code ive enclosed the instructions in Do loop and if the file doesnt exist i want to skip the code and loop to the next file.

View 6 Replies

VS 2008 DataReader Error In Looping

Mar 29, 2009

[code]I am facing difficulty in coding when intRow loop for the 2nd round. Error message "There is already an open DataReader associated with this Command which must be closed " appear in the above red highlight vb.net code.

View 6 Replies

VS 2008 Fill Array With DataReader?

Jan 11, 2011

How can I fill this Percentage array with Sql data reader..

Dim StudentID As Integer = Me.ComboBox1.SelectedValue
Dim Percentage() As Integer
Dim con As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=D:Database

[code].....

View 5 Replies

VS 2008 Fill ComboBox With DataReader?

Mar 16, 2010

The code works fine, but I don't know if is necessary while sentence, maybe there is another option..

Dim CMD As New OleDb.OleDbCommand
CMD.Connection = otraConexion
CMD.CommandText = "SELECT * from procedencias"

[Code]....

View 3 Replies







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