Reader produces no results at allhttp://forums.asp.net/t/1813440.aspx/1?Reader+produces+no+results+at+allMon, 18 Jun 2012 02:00:30 -040018134405022486http://forums.asp.net/p/1813440/5022486.aspx/1?Reader+produces+no+results+at+allReader produces no results at all <p>The following code seems to produce nothing.</p> <p>No errors, no exceptions, no results as all.</p> <p>Can some please tell me where I am goofing up? &nbsp; &nbsp;Thanks!!</p> <p>If it makes a difference, I am using ASP.Net 2.0</p> <p>The Connection is to a Access DB.</p> <p></p> <pre class="prettyprint">Dim strConnection As String = ConfigurationManager.ConnectionStrings(&quot;clocknoConnectionString&quot;).ToString() Dim conn As New SqlClient.SqlConnection(strConnection) Dim comm As New SqlClient.SqlCommand(&quot;SELECT [EmpNo], [Name] FROM [clockno] WHERE [EmpNo] = @EmpNo&quot;, conn) comm.Parameters.Add(New SqlClient.SqlParameter(&quot;@EmpNo&quot;, OleDb.OleDbType.Char, 10)) comm.Parameters(&quot;@EmpNo&quot;).Value = txtEmpNo.Text conn.Open() Dim reader As SqlClient.SqlDataReader = comm.ExecuteReader() If reader.Read And reader.HasRows Then lblEmpNo.Text = reader(&quot;EmpNo&quot;) lblEmpName.Text = reader(&quot;Name&quot;) Else Response.Write(&quot;Clock # Not Found. Click back on your Browser&quot;) End If</pre> <p><br> <br> </p> 2012-06-12T16:10:11-04:005022572http://forums.asp.net/p/1813440/5022572.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>I did find a mistake in my code.</p> <pre class="prettyprint">comm.Parameters.Add(New SqlClient.SqlParameter(&quot;@EmpNo&quot;, <strong>SqlDbType</strong>.Char, 10))</pre> <p>However it still produces no results!<br> <br> </p> 2012-06-12T17:41:23-04:005022714http://forums.asp.net/p/1813440/5022714.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>Here is the connection string for my Access DB.</p> <pre class="prettyprint">&lt;connectionStrings&gt; &lt;add name=&quot;clocknoConnectionString&quot; connectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Mode=Read;Data Source=E:\Web\rhi\databases\clockno.mdb&quot; providerName=&quot;System.Data.OleDb&quot; /&gt; &lt;/connectionStrings&gt;</pre> <p></p> <p>Should I be using a different connection string now? &nbsp;</p> <p>If so, why does this connection string work fine on the ASPX page when used by a SQLDataSource?<br> <br> </p> 2012-06-12T20:17:42-04:005024577http://forums.asp.net/p/1813440/5024577.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>No one has given any suggestions.</p> <p>Have I posted this int the wrong forum category?</p> <p>Is there a more appropriate category to post this question?</p> 2012-06-13T19:09:22-04:005024591http://forums.asp.net/p/1813440/5024591.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>Hi,</p> <p>can you chage your code like instead of using data reader use data set. becuase u can find is it reader problem or data fetching problem.</p> <p></p> <p>Looser.</p> 2012-06-13T19:21:05-04:005024706http://forums.asp.net/p/1813440/5024706.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>Here is the code I used to try it as a datset.</p> <p>No change in the output though. (which is nothing)</p> <pre class="prettyprint">Dim adapter As New SqlClient.SqlDataAdapter Dim ds As New DataSet Dim tables As DataTable Dim i As Integer Dim sql As String Dim connetionString As String = ConfigurationManager.ConnectionStrings(&quot;clocknoConnectionString&quot;).ToString() Dim SqlConnection As New SqlClient.SqlConnection(connetionString) Dim SqlCommand As New SqlClient.SqlCommand(&quot;SELECT [EmpNo], [Name] FROM [clockno] WHERE [EmpNo] = @EmpNo&quot;, SqlConnection) SqlCommand.Parameters.Add(New SqlClient.SqlParameter(&quot;@EmpNo&quot;, SqlDbType.Text)) SqlCommand.Parameters(&quot;@EmpNo&quot;).Value = txtEmpNo.Text SqlConnection.Open() adapter.Fill(ds, &quot;SQL Temp Table&quot;) adapter.Dispose() SqlCommand.Dispose() SqlConnection.Close() For Each tables In ds.Tables Response.Write(tables.TableName) Next</pre> <p><br> <br> </p> 2012-06-13T20:58:34-04:005025803http://forums.asp.net/p/1813440/5025803.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>For Troubleshooting, I took out the Try - Catch .</p> <p>I tried displaying the variables on screen to troubleshoot.</p> <p>Response.Write(connetionString)</p> <p style="padding-left:60px">Works Fine</p> <p>Response.Write(SqlConnection)</p> <p>I now get a error.</p> <h1>Server Error in '/' Application.</h1> <hr color="silver" size="1" width="100%"> <h2><i>Keyword not supported: 'provider'.</i></h2> <p><span face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif " style="font-family:Arial,Helvetica,Geneva,SunSans-Regular,sans-serif"><b>Description: </b>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. <br> <br> <b>Exception Details: </b>System.ArgumentException: Keyword not supported: 'provider'.<br> <br> </span></p> <pre>Line 78: 'Find Employee in database Line 79: ' Try <span color="red" style="color:red">Line 80: Dim SqlConnection As New SqlClient.SqlConnection(connetionString)&nbsp;</span></pre> <pre>Line 81: Dim SqlCommand As New SqlClient.SqlCommand(&quot;SELECT [EmpNo], [Name] FROM [clockno] WHERE [EmpNo] = @EmpNo&quot;, SqlConnection) Line 82: Response.Write(SqlConnection)</pre> 2012-06-14T12:21:41-04:005025825http://forums.asp.net/p/1813440/5025825.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>The more I think about this, it seems the provider connection strig is setup wrong to use sqlconnection with a Access db.</p> <p>If that's the problem, the question still remains from post 3 above, &quot;why does this connection string work fine on the ASPX page when used by a SQLDataSource?&quot;</p> <p></p> 2012-06-14T12:32:15-04:005028075http://forums.asp.net/p/1813440/5028075.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p>Since I have made virtually no proggress since the orginal post, I am going to move the database over to a MySQL server I have access to.</p> <p>I have to believe I will have better luck there.</p> <p></p> <p></p> 2012-06-15T20:42:08-04:005029419http://forums.asp.net/p/1813440/5029419.aspx/1?Re+Reader+produces+no+results+at+allRe: Reader produces no results at all <p></p> <blockquote><span class="icon-blockquote"></span> <h4>gene7135</h4> Mode=Read;</blockquote> <p></p> <p>Please remove this:)</p> <p>I notice a very serious problemSince you are now using Access dbso please use OleDbConnection&#43;OleDbCommand instead of SQL ones</p> <p></p> 2012-06-18T02:00:30-04:00