SQL Server :: Can't Read New Data From Database

Apr 1, 2011

I am trying to read data from a SQL Server 2008 database. Initially, I imported a 2007 Access db into the server. I have no problem reading this data. However, if I add new data, either through code or through SQL commands on the Server, I get an error when I try to subsequently read it. I only get the error on new data, not the imported data. Error:

System.InvalidOperationException: Invalid attempt to read when no data is present.

In my page (ASP.NET/VB.NET) I have a dropdown box which is filled with Customer Names. No Problem there. However, when I choose the customer, the rest of the form is supposed to fill with data retreived from the database. If I choose original data, it works fine. However, as soon as I choose a newly added record. It throws the Exception. I have tried to find a solution online, but most answers point to missing read code. I think my code is right, as it reads some records correctly. Is there something that is wrong with my server, or the way I am writing the records?

There is a dropdown box name CNAME on my page...

OnSelectedIndexChanged runs the following code:

sub displaydata(s as Object,e As EventArgs)
locked.checked = "True"
edit.enabled = "False"
Dim CustomerName As String = CNAME.SelectedItem.Text
Dim dread as SqlDataReader
Dim cn As New SqlConnection()
Dim cd As New SqlCommand()
cn.ConnectionString = "Data Source=localhost;Initial Catalog=AnalyticalReports;Integrated Security=True;"
cd.Connection = cn
cd.CommandText = "select Customers.CID, Customers.CNAME, Customers.CADDRESS1, Customers.CCITY, Customers.CSTATE, Customers.CZIP, Customers.CCONTACT, ISNULL(Contacts.CONNAME,'none') AS CONNAME FROM Customers JOIN Contacts ON Customers.CCONTACT = Contacts.CONID
WHERE Customers.CNAME = '"+ CustomerName+"'"
cn.Open()
dread = cd.ExecuteReader()
dread.Read()
CID.Text = dread("CID")
CNAME2.Text = dread("CNAME")
CADDRESS1.Text = dread("CADDRESS1")
CCITY.Text = dread("CCITY")
CSTATE.Text = dread("CSTATE")
CZIP.Text = dread("CZIP")
CONNAME.Text = dread("CONNAME")
cn.Close()
dread.close()
End Sub

View 4 Replies


Similar Messages:

SQL Server :: Parsing An Array Read From An MS Database/'System.Data.SqlClient.SqlDataAdapter' Does Not Contain A Definition For 'Rows'...

Mar 23, 2011

I am getting this error:

CS1061: 'System.Data.SqlClient.SqlDataAdapter' does not contain a definition for 'Rows' and no extension method 'Rows' accepting a first argument of type 'System.Data.SqlClient.SqlDataAdapter' could be found.

Here is my code, what am I doing wrong?:

[Code]....

View 4 Replies

SQL Server :: Read A Value From Database?

Dec 3, 2010

I want to read a value from database, using stored procedure i will paste my code below

ALTER
PROCEDURE [dbo].[msp_exceedingtimesheet]

-- Add the parameters for the stored procedure here

@Fullname nvarchar(50)
AS
BEGIN

[Code]....

View 2 Replies

SQL Server :: Read Next Row And Previous Row In Database?

Mar 25, 2011

how to make it?? How to read next row and previous row in database / SQL

View 5 Replies

SQL Server :: Failed To Update Database Because Read - Only

Oct 1, 2010

I am currently working on visual studio 2008 , sql express 2005, i have copied .mdf and .ldf files , after i copied these files and try execute some existing stored procedure but exception is coming like " Failed to update database xxxxxxxxxxxxxxxxx.MDF" because the database is read-only", I dont knw what's wrong with this , i have executed same stored procedure in old .mdf and .ldf database , and its working fine . but in copied .Mdf , not working.

View 10 Replies

Web Forms :: Read And Import Excel Sheet Into SQL Server Database?

Apr 23, 2012

I used the code posted on the link [URL]....

I'm getting the following error

"The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"."

 I am running SQL 2005 on Windows SBS 2003 server.

Also on solution 3 you running the below sql query

Do i need to run it on the master database or on my database?

USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO

View 1 Replies

Web Forms :: Read Character Delimited File And Insert Records Into SQL Server Database

Aug 10, 2012

I am having a list of contents in the notepad.

I having the following content.

000012|vasanth|Sofware Engineer|Chennai|

0000215|Arun|ASE|Keral|

The field is static and the column name is ID,name,Designation,City.

I need to read the note pad charecter by charecter and i have to insert the records corresponding in the field which is seperated by "|".

View 1 Replies

ADO.NET :: How To Read Data From Database

Feb 23, 2011

I am uisng asp.net 3.5 with c# as language. I want to read the database and store the data in either array or arraylist so that it can be called further in a dropdown list.

View 4 Replies

ADO.NET :: Read Data From A Database Table 'Tablename'?

Sep 3, 2010

I got this message while trying to read data from a database table 'Tablename'

Invalid object name 'tableName'

[Code]....

View 4 Replies

DataSource Controls :: Read Data Of From A Sql Database?

Feb 24, 2010

i am trying to read data of from a sql database

the code that im using is as follows:

[Code]....

as you can see, im using table adapters - though when i run the page, it throughs me the following error, which i'm finding hard to understand

for my last project, i had to use the exact code, but at the time, i was using an access DB and now i'm uning sql D|B

the only difference from last time is that instead of using :

using System.Data.OleDb;

Now im using: using System.Data.SqlClient; //sql server

View 4 Replies

DataSource Controls :: Read Data From An Access Data File And Input Into The SQL Database?

Mar 10, 2010

I have a lot of members data to enter into the ASPNETDB database. How can I read this data from an Access data file and input into the SQL database. All data is for user Names and Password,

View 1 Replies

Data Controls :: Read Data From Excel File - Encrypt And Save In Database

May 7, 2015

I have an excel file with data as follows

ID     Name     Contact No    Address  
1      ABC        XXXXXXX     ABCNM2    
 XYZ         xxxxxxx       ASDFG

Now my requirement is read data from this excel sheet and den encrypt Contact No field for each row and den save data in database, how should it will be done I have to use some ready made available encryption algo for that. 

View 1 Replies

Read & Update A Single Record In A Data Set And Then In The Database?

Mar 15, 2010

how to use update using ADO.NET dataadapters.

View 2 Replies

DataSource Controls :: Read And Insert Data Into Database?

Mar 5, 2010

I m uploading a text file. I want to read that text file line by line and I want to save that data into database if there are no errors in that text file. I have 5 different columns in database and I want to take those 5 columns data in the text file and insert into respective columns.

For this, which is the best way to do. Can we read and insert data into respective fields in no time.

View 2 Replies

Databases :: Cannot Read CLOB Data From Oracle Database In C# 4.0

Feb 4, 2011

am in deep trouble with retriving the data from oracle database. Please HELP ! In one line: "When i retrive the data from oracle database, it's truncate the data if it is more than 4 kb"I have oracle proc param as below:

PROCEDURE p_GetData (
ivar_id IN id_n%TYPE,
oclb_owners OUT CLOB,
onum_sqlcode OUT NUMBER,
[code]...

View 8 Replies

C# - Read The Data From A Text File Stored In The Database?

Apr 15, 2010

I have a text file stored in my sql DB. in that .txt file I have certain numbers like:

99435
87889
33455
33555
34556

How to get the count of these numbers from the txtfile stored in the database? Also to read the file and fetch the number one by one in a string? I am using asp.net (C#)

View 1 Replies

Forms Data Controls :: Cannot Read The Database Values Into Textbox

Dec 3, 2010

protected void Button1_Click(object sender, EventArgs e)

View 3 Replies

DataSource Controls :: How To Read Data And Perform Action From The Database

May 3, 2010

i'm quite new to asp.net and have been working on a simple way for users to send messages to each other....

the messages work fine, users can send and reply, however, i want a way to tell the users when they have a message and how many...

how to do this in simple terms and supply vb code if possible.

View 2 Replies

Forms Data Controls :: Read PDF Using (C#.net) And Store Values In Database?

Oct 11, 2010

Please try to guide me how to achieve this one. my application need to do reading the PDF document and want to store the values in Database.Actually what happens is my customers sends me the OCR scanned copied in the form of PDF file. i need to read those scanned pdf files and store the customer information into my table.

View 1 Replies

Forms Data Controls :: Connect To Database And Read Records?

Dec 10, 2010

i write program in asp.net that this program connect to database frequency and database has very records, i search about solution that i connect to database for one time and another time i use this information and when table records was updated , my program connect to database twice...(for example my program connect to database one time and later when only records was updated ,connect to database...)

View 1 Replies

Web Forms :: Creating Content Pages - Read Data From Database And Display On Template

Jan 4, 2011

I am working on a medium size web site and I am kind of stuck. I need to do the following

1- admin user fill a form and submit (Done)
2- the system create new page storing the info provided in step 1

how can I do that? I need a page to be created I don't want to read the data from data base and display it on a template

View 1 Replies

Forms Data Controls :: Repeater Template-Render Different HMTL Based Off Database Read?

Feb 4, 2011

I have my repeater loading in plain text from a database right now e.g.

<td>
<a href="<%# DataBinder.Eval(Container.DataItem, "URL")%>">
<img alt="<%# DataBinder.Eval(Container.DataItem, "AltTag_Thumbnail")%>" src="<%# DataBinder.Eval(Container.DataItem, "URL_Thumbnail")%>" />
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Name") %>
</td>

My plain texts are image links and pdf URLs from a database table, in groups, in the correct order but I'm not sure how to render them correctly (sample image below shows what I am trying to render)

Is there any way to make a repeater template intelligent enough to render an "image link" OR "pdf link" based off the [type] column returned in the record?

table:
pk
Name
Type (image or pdf)
URL
Description
URL_Thumbnail (if image)
GroupId (associate these records to each other)
OrderNumber (order of these records within their GroupId)

View 4 Replies

Data Controls :: Server Error - Invalid Attempt To Read When No Data Is Present

May 7, 2015

This is the problem:

Server Error in '/AviaBellaVidaChecklist' Application.

Invalid attempt to read when no data is present.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.

View 1 Replies

SQL Server :: How To Read Comma Delimited Data From A Column

Feb 23, 2011

I am creating a BLOG and Forum, and am using tags similar to this and most other sites, I just need to know how to retrieve the tags from a culmn if the tags are stored with commas separating them, I am sure I read about it somewhere but was unable to find it.so the column would be:

tag1, tag2, tag3, etc.....

I would need to be able to:

1. Store tags, and add-on to tags already in the column

2. retrieve the tags as a list, or separately

View 5 Replies

SQL Server :: System.InvalidOperationException: Invalid Attempt To Read When No Data Is Present?

Aug 27, 2010

Invalid attempt to read when no data is present.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.Source Error:

[Code]....

Here is my code:

[Code]....

What am i doing wrong?

View 4 Replies







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