DataSource Controls :: DataTable With DataReader Not Working?
May 17, 2010dataTable with dataReader not working
[Code]....
dataTable with dataReader not working
[Code]....
I have used SqlDataReaders a million times. Someone, what is wrong with this code:
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.Open();
SqlCommand command = connection.CreateCommand();
[Code]....
I have checked this against similar classes and it is exactly the same, but this one doesn't work.
This is the code i am used for fetching data from DB2 server (windows based server)In the same server tables created by me is working fine...eg:
oCommand.CommandText = "SELECT * from DEB.TESTUSER";
below is a table created by another application but the data reader is not working with this query ( table in the same server with same DB as above)
oCommand.CommandText = "SELECT * FROM DEB.RULE_GROUP";
If any permission or any other things i want to check .....i mean security related.....odbcadapter is also working fine....pls help regarding the datareader.....below is the complete code......
private void btnSelectRecord_Click(object sender, EventArgs e)
{
OdbcConnection oConnection = null;
[code]...
Dim dt as datatable = test.select()
dt.DefaultView.Sort = "col1 ASC"
for each dr in dt.rows
response.write(dr.item("col1"))
next
I had found out the sorting command is "dt.DefaultView.Sort", but why is it not working. Can someone shed a light.
I have no problem when paging my FormView, the dropdownlist does not read the next record and keep the value of the first loaded record? All other textbox control behave normally and move from record to record excepted the ddl??Here the code.
Public Sub DoData()
Dim myConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)
Dim myCommand As SqlCommand = New SqlCommand("SelectSupplier", myConn)
myCommand.CommandText = "SelectSupplier"
[Code]....
i'm developing a website to my office, i have a question related data loadinf performance related.
dataadapter.Fill() or dataTable.Load(Datareader) give the best performance in asp.net ??
see i want to fill datatable using datareader.
i have created object like this
SqlDataReader dr=cmd.ExecuteReader();
if(dr.HasRows)
{
}
I have put a SQLDataSource on my page and everything is adjusted and it works properly. I read an article
here which was indicating that you can use a DataReader in order to get data from sqldatasource, but it doesn't say how, the only thing that is said is to use DataSourceMode property in order to adjust it for a DataReader.
How do I load a datareader in a defult.aspx page using while using a database connection that is defined in the web.config file?
View 3 Repliesi have the dataset with one table.Table contains three column like 'Name','Location','Pin'.I would like to move the data from another table based on schema.
View 2 Replieswhy this first connection works but the second doesn't?
[Code]....
I'm trying to use <asp:FileUpload> to upload images and as far as I know you have to use <asp:SqlDataSource> to do it but I need to create the connections string using entries stored in a database.
Dim sqlc1 As New SqlCommand("sp_navmenu 275,1,21", ERIKSDbCon)
View 4 RepliesWhen a sql query returns NULL , I can use the following code to evaluate:
[Code]....
When a sql query returns nothing, neither IsDBNull nor is Nothing works. I don't know why some sql queries return null while some return nothing when there are no data returned. But anyway, can somebody tell me how to evaluate nothing value returned in sql datareader in vb.net? When I put the cursor over signInfo variable in debug mode, I can see Nothing show as its value. But the line does not work
[Code]....
Any one can suggest a method to convert Datareader to dataset or any alternate method
View 7 RepliesI would like to loop through my result set and generate a menu structure like this:
pagetitle
pagetitle
subtitle
subtitle
pagetitle
pagetitle
So far I have the following code but it doesn't generate the menu?
While reader.Read()
' set title
sitetitle = reader.Item("siteName")
mydata &= reader.Item("pagetitle")
' check subtitle exists, if so, build menu, loop though subtitles somehow?
if not IsDBNull(reader.Item("subtitle"))
mydata = "<ul>"
mydata &= "<li>" & reader.Item("subtitle") & "</li>"
mydata &= "</ul>"
end if
End while
Qeury and result set below:
sql:
SELECT subpages.subpageid, pages.pageid, sites.sitename, sites.siteid, pages.siteid,pages.pagetitle, subPages.subtitle FROM pages LEFT JOIN sites ON pages.siteid = sites.siteid LEFT JOIN subpages ON subpages.subpageid= pages.pageid WHERE sites.siteID = 1 ORDER BY sites.siteid, pages.pageid, subpages.subpageid ASC
results:
subpageid | pageid | siteid | siteid | pagetitle | subtitle
NULL 1 SCHS 1 1 Sandwell Community Healthcare Services NULL
NULL 2 SCHS 1 1 About Us NULL
NULL 3 SCHS 1 1 Your Services NULL
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 1111
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 2222
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 333
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 44444
NULL 5 SCHS 1 1 Single Equality Scheme NULL
NULL 6 SCHS 1 1 Diversity Strands NULL
NULL 7 SCHS 1 1 Equality Impact Assessments NULL
NULL 8 SCHS 1 1 Quality and Safety Committee NULL
NULL 9 SCHS 1 1 Contact Us NULL
protected void Page_Load(object sender, EventArgs e)
View 7 RepliesI have text field on a sql server table and I retrieve it on string variable using datareader : string result = reader["MyTextfied"] but I have this errors ( text or binary field cannot be troncated ) My text fied contains a large of text
View 5 Repliesi have a datareader who read from data field from sql server, this field is datetime format now, when this field is null it returns 01/01/1900!! how can i manage it without if or some check, is there a property in datareader or sqlserver properties who i can return null value from datetime field?
View 4 RepliesI use a SqlDataReader to get fron sqlServer a row af a table. This table have a text field where I store a Xml configuration. In one case this Xml grow up to 650Kb. When I get the field from the datareader it cost amost 2 seconds:
INFO 2010-04-16 09:46:40,559 [12] Cms.dataContenido - readed
INFO 2010-04-16 09:46:42,356 [12] Cms.dataContenido - XMLContent
This is my code:
[Code]....
I'm Using a DataReader to Read about 100,000 records, my code look like :
[Code]....
I have a per row computation in reading the rows on GetMyType2Info() method, and this method also another method that I return only one record by ExecuteReader(). the problem is that when the MyTypeList (List<T>) has about 21,000 Items of MyType (<T>) System.OutOfMemoryException is thrown. wanted to know how to resolve this and wanted to know more about the maximum size of List<T> capacity. in addition the execution of the main Query with 100,000 records take about 4 seconds in SQLServer a record has only types of nvarchar , float,datetime and int
I have two datatables, I want to get all records which are in one datatable but all matching records which exist in another datatable should not be available.
In terms of set, you can say that record which are in 1st datatable but not in 2nd DataTable.
I am using MS SQL Server 2005 and i added "" to my connection string and i still have the problem
"There is already an open DataReader associated with this Command which must be closed" ;
SqlDataReader dr2;
StrSql = " SELECT * from Modules";
cmd.Connection = conn;
cmd.CommandText = StrSql; [code]....
I'm having a method that exports content from the database to excel files. The method taks as paramaters a DataReader param and a int param - the number of rows. For the number of rows i'm using a dataset, wich i fill using the same query as for the datareader. So I'm executing it twice... Is there a way I can avoid that? get the number of rows from the datareader?
View 1 RepliesI am getting an error that an open DataReader associated with this Command, when I'm not using datareader(though probably executereader() is the same thing) how would I close this if I don't have a datareader present?
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("spSelectAllTypes",conn);
cmd.CommandType = CommandType.StoredProcedure;
[code]...
I just want to be able to databind a bunch of dropdownlist in one open connection. (before I had multiple open and closes for each control)
I mean, what is the faster way to get as fast as I can more than one table with stored procedure? Is there any study what is faster and why? There is a big problem getting more than one table at once with Entities, so the only way is DataSet. But I was told DataSet work very slow. Is that true?
View 2 Replies