sqldatareader

Datareader Retrieving Data

老子叫甜甜 提交于 2019-12-02 13:32:59
I have Memberships and Bookings tables in a database containing an attribute cust_id, which is the primary key in Memberships and reference key in Bookings. When I am executing a data reader I want it to read cust_id values from membership table but it is reading it from the bookings table. Also, when I compare two cust_id values, 1 taken from a textbox and the other taken a from database column, even though both are the same, but the comparison result is false. I have compared using string.equals(str1, str2) and have also compared the two directly using if statement. But in both cases, even

Invalid attempt to Read when reader is closed

蓝咒 提交于 2019-12-02 12:46:09
I'm working on C# and MySql request. I'm trying to retrieve my datas in my db but I have this error message : Invalid attempt to Read when reader is closed. Thanks for your help guys :) I have this function : public MySqlDataReader GetValueFromTable(string table, ArrayList attribut, ArrayList parameter) { string query = string.Empty; MySqlDataReader rdr = null; try { query = "SELECT * FROM `" + table + "` WHERE "; for (int i = 0; i < attribut.Count; i++) { query += attribut[i] as string; query += " = "; query += parameter[i] as string; if(i != attribut.Count - 1) query += " AND "; } query += "

How do I execute a SELECT query against a SQLServer database and iterate results using PowerShell

天涯浪子 提交于 2019-12-02 11:53:17
Say I have a table with 3 columns - "Column1", "Column2", and "Column3" - datatype is varchar(100) for all 3. Using PowerShell, how do I connect to SQL Server and use SqlDataReader and ForEach operator to view the contents of "Column2"? Here's roughly how I'm doing it: $SqlServer = 'sql.example.com'; $SqlDatabase = 'MyDB'; $SqlConnectionString = 'Data Source={0};Initial Catalog={1};Integrated Security=SSPI' -f $SqlServer, $SqlDatabase; $SqlQuery = "SELECT Name FROM dbo.Person ORDER BY Name;"; $SqlConnection = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList

SqlDataReader hangs on GetValue() method and SNIReadSyncOverAsync

寵の児 提交于 2019-12-02 11:34:16
问题 We have an extremely weird problem at hand. The .Net SqlDataReader object gets stuck while reading a value on GetValue() method. There are no exceptions and it does not timeout for at least more than 10 minutes which is really long time. After more than 10 minutes, it throws this error: General Exception - !ET:SqlException{CRLF}!M:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.{CRLF}General Exception - !ET:Win32Exception{CRLF}

C# - Web Site - SQL Select Statement

我只是一个虾纸丫 提交于 2019-12-02 11:16:15
问题 I want to use a select statement to find if there is a record that already exists. I've put the code below but it throws an error at the dReader = comm.ExecuteReader(); and i'm unsure why. Any help? string connString = "Data Source=KIMMY-MSI\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"; SqlDataReader dReader; SqlConnection conn = new SqlConnection(connString); SqlCommand comm = new SqlCommand(); comm.Connection = conn; comm.CommandText = "SELECT * FROM Customers WHERE

SqlDataReader hangs on GetValue() method and SNIReadSyncOverAsync

我是研究僧i 提交于 2019-12-02 06:23:08
We have an extremely weird problem at hand. The .Net SqlDataReader object gets stuck while reading a value on GetValue() method. There are no exceptions and it does not timeout for at least more than 10 minutes which is really long time. After more than 10 minutes, it throws this error: General Exception - !ET:SqlException{CRLF}!M:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.{CRLF}General Exception - !ET:Win32Exception{CRLF}!M:The wait operation timed out{CRLF}! Stack trace obtained through process dump. 000000001b2ee6f8

Gridview not populating while using a While() structure. C# ASP.Net

拈花ヽ惹草 提交于 2019-12-02 05:36:22
问题 I am having problems with this grid view. I am populating it with a query. However, it will not populate or even appear if I use a while(reader.Read()) structure. Without the while structure, it works fine. However, I need to access two specific fields. The code is below. SqlDataReader myReader; try { using (myConnection) { myConnection.Open(); ArrayList arrliGames = new ArrayList(); myReader = myCommand.ExecuteReader(); decimal decTicketCost = 0; int intTicketCount = 0; while (myReader.Read

Drop down list not binding with sqldatareader

随声附和 提交于 2019-12-02 04:41:51
i have a form with a collection of about five drop down . i have my query as follows . string sql = "SELECT a.clientID ,a.[cname],b.bid,b.[bname],c.contactID, c.[name] FROM " + " dbo.[CLIENT] AS a INNER JOIN dbo.[BRANCH] AS b " + "ON a.clientID = b.clientID JOIN dbo.[CONTACT] AS " + " c ON b.bid = c.bid ORDER BY a.clientID "; i then followed and bind my drop down individually to their respective columns as follows. SqlCommand cmd = new SqlCommand(sql, connection); cmd.CommandType = CommandType.Text; SqlDataReader reader = cmd.ExecuteReader(); drClient.Enabled = true; drClient.DataSource =

C# - Web Site - SQL Select Statement

风流意气都作罢 提交于 2019-12-02 04:02:40
I want to use a select statement to find if there is a record that already exists. I've put the code below but it throws an error at the dReader = comm.ExecuteReader(); and i'm unsure why. Any help? string connString = "Data Source=KIMMY-MSI\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"; SqlDataReader dReader; SqlConnection conn = new SqlConnection(connString); SqlCommand comm = new SqlCommand(); comm.Connection = conn; comm.CommandText = "SELECT * FROM Customers WHERE CustomerID == " + txtID.Text; comm.Connection.Open(); dReader = comm.ExecuteReader(); if (dReader.HasRows ==

SqlDataReader does not return all records (3rd attempt)

痴心易碎 提交于 2019-12-02 03:04:58
问题 I've tried to find solution for this problem twice before, but unfortunately those answers haven't provided permanent fix, so here I am, giving it another try. I have an SQL Server stored procedure that returns list of 1.5 million integer IDs. I am calling this SP from ASP.NET/VB.NET code and executing a SqlDataReader: m_dbSel.CommandType = CommandType.StoredProcedure m_dbSel.CommandText = CstSearch.SQL.SP_RS_SEARCH_EX oResult = m_dbSel.ExecuteReader(CommandBehavior.CloseConnection) Then I am