Hey,
What might the code you are using look like?
|||
here's my connection string in the web.config -- minus user id and password, and an example of how I'm trying to pull data
<
addname="SQLConnString"connectionString="Data Source=UELIIS;Initial Catalog=ITtech;Persist Security Info=True;User ID=*****;Password=*****"providerName="System.Data.SqlClient"/>
PrivateSub GetMaxVendorNum()
Dim NextVendorNumAsString
strSql =
"SELECT MAX(VendorNum) + 1 AS Expr1FROM Vendor"dr = GetDataReader(strSql, strConn)
If dr.Read()Then
NextVendorNum = dr(
"Expr1").ToStringlblVendorNum.Text = NextVendorNum.ToString
EndIfEndSubPublicSharedFunction GetDataReader( _ByVal SQLStatementAsString, _ByVal ConnectionStringAsString)As SqlDataReaderDim drAs SqlDataReaderDim cmdAsNew SqlCommandWith cmd.Connection = _
New SqlConnection(ConnectionString).Connection.Open()
.CommandText = SQLStatement
dr = .ExecuteReader(CommandBehavior.CloseConnection)
EndWithReturn drEndFunction
Thanks for your help
|||Hey,
I tried your query, and that worked for me. The only thing I can think of is the fact that you are returning the data reader and something is happening in between. Is the problem that you are getting no entries or that you are getting an error thrown.
|||I'm just not getting any entries, just blank fields|||The really crazy thing is that on my first page I'm using a sqldatasource to populate a gridview and it pulls and displays the information with no problem. Its using the same connection string as my other pages.|||well i've narrowed it down to the fact that my page_load event isn't firing for some reason, I even tried to put a script tag in the .aspx page and place it there instead of a code behind page but still nothing, can't even put text into the error label. Here's some of my code snippets that may help troubleshoot problem.
<%
@.PageLanguage="VB"AutoEventWireup="false"CodeFile="VendorEdit.aspx.vb"Inherits="VendorEdit" %>Partial
Class VendorEditInherits
System.Web.UI.Page.... CODE.....
end class
Ask if you need to see any code or need more information. Thanks for your help.
|||Hi,
Thanks for your code.
I tried it on my machine and it works fine. The only problem seems that I cannot see any code that your DataReader is binding to. Did you set it as the datasource of a GridView?
If so, please also call GridView.DataBind() after it has been set as the DataSource.
HTH.
|||could you post your page_load event code make sure its something like following
Protected
Sub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.LoadEndSubhandles me.load is must.
thanks,
satish.
No comments:
Post a Comment