but in my page.
<asp:hyperlink ID="superemail1" NavigateUrl="mailto:" & empDS.tables("employeeinfo".Rows(0).Item("supervisoremail" & ""></asp:hyperlink>
I am guessing my NavigateUrl is formated wrong to. Basically I need to have the words mailto: followed by whatever is in that database field.
this is in your code-behind??
If you are using VS then this following line is auto added when you drag the hyperlink object on the page. If you manually added it by typing you need this in your code behind.
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink That'l do donkey, that'l do
Mark
Ya that is what I meant as long as you are loading the dataset somewhere.
Now I am guessing that you have your dataset declared in the Page_load sub? If you have this is why you get the error message. Make sure to declare it outside of the sub so that it still exists once you get down to the data binding bit. That'l do donkey, that'l do
Mark
I haven't actually worked in code that isn't code-behind, however the same concepts do apply. And yes you are on the right track. Simply declare the dataset at the top of you page within some script tags. Don't put the declaration in a sub or the variable only lasts for the duration of the sub or function. Then fill your dataset in the page_load event and it should work fine in the databinding bit. That'l do donkey, that'l do
Mark
If I am understanding you correctly I put the code like this
<script runat="server">
Dim dbconn1 As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;"
Dim selectCMD5 As SqlCommand = New SqlCommand()
selectCMD5.CommandText = "Select * from employeeinfo where userID = '" & request.servervariables("AUTH_USER" & "'"
selectCMD5.Connection = dbconn1
dbconn1.open
if selectCMD1.ExecuteNonQuery() = 0 then
selectCMD5.CommandText = "Select * from employeeinfo where userID = 'AM1ST_DOMAIN\" & request.servervariables("AUTH_USER" & "'"
end if
dbconn1.close
selectCMD5.CommandTimeout = 30
Dim empDA As SqlDataAdapter = New SqlDataAdapter
empDA.SelectCommand = selectCMD5
dbconn1.Open()
Dim empDS As DataSet = New DataSet
empDA.Fill(empDS, "employeeinfo"
dbconn1.Close()
Public Sub Page_Load(Source as Object, E As EventArgs)
'code here
End Sub
This produces the following error though, Why? this code works when enclosed in a sub?
Line 10: Dim selectCMD5 As SqlCommand = New SqlCommand()
Line 11:
Line 12: selectCMD5.CommandText = "Select * from employeeinfo where userID = '" & request.servervariables("AUTH_USER" & "'"
Line 13: selectCMD5.Connection = dbconn1
Line 14: dbconn1.open
I was trying to make better code out of my mess that I had and wondered why this doesn't return anything? I get no errors, and no text is shown. Am I calling the function wrong?
Function MyFunction() As String
Dim dbconn1 As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;"
Dim selectCMD5 As SqlCommand = New SqlCommand()
selectCMD5.CommandText = "Select * from employeeinfo where userID = '" & Session("whosonline" & "'"
selectCMD5.Connection = dbconn1
selectCMD5.CommandTimeout = 30
Dim empDA1 As SqlDataAdapter = New SqlDataAdapter
empDA1.SelectCommand = selectCMD5
dbconn1.Open()
Dim empDS1 As DataSet = New DataSet
empDA1.Fill(empDS1, "employeeinfo"
dbconn1.Close()
do you have access to query analyer for that sql server? if so try runningt the select command you have there on the server. The code looks fine, it looks like there is no data there.
The other thing is your where clause. Should you have spelt the session variable whosonline differently when you assigned it you would get the following select. Select * from employeeinfo where userID = ''
which will return a blank dataset also giving your described results. That'l do donkey, that'l do
Mark
I ran the select statement through the query analyer by changing the session variable to a value I knew was in the database and it returned a result. When I changed it to the same statement in the function it returns nothing to the page.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.