narmi2
asked on
SQL Query not working in webform?
Hi
I'm having problems with this sub. When i run the sql query in this sub in query analyser, it returns 1 email e.g. narmi@home.com
But when I run the following sub on page load of my webform, it only returns the word "email" in the textbox1.
Anyone know why this is happening?
'-------------THE CODE STARTS HERE---------------
Sub EmailSender()
Dim xCN As String = Request.ServerVariables("L OGON_USER" )
Dim xllength As Integer = xCN.Length
Dim xemp_code As String = xCN.Substring(xllength - 3, 3)
Dim TestURL As String = "../employees/basic_detail s.aspx"
objSelectDataAdapter = New SqlDataAdapter("SELECT CASE WHEN tb2_from_db1.internet_addr is null THEN " & _
"lower(tb2_from_db1.first_ name) + '.' + lower(tb2_from_db1.last_na me) + '@home.com' " & _
"WHEN tb2_from_db1.internet_addr like '%post%' THEN " & _
"lower(tb2_from_db1.first_ name) + '.' + lower(tb2_from_db1.last_na me) + '@home.com' " & _
"ELSE lower(tb2_from_db1.interne t_addr) " & _
"END As [email] " & _
"FROM db1.dbo.hbm_persnl tb1_from_db1, " & _
"db1.dbo.hbm_name tb2_from_db1, " & _
"db2.dbo.ps_tb1_from_db2_e mails tb1_from_db2, " & _
"db2.dbo.ps_task_sub(tb2_f rom_db2) " & _
"WHERE(tb1_from_db1.name_u no = tb2_from_db1.name_uno) " & _
"AND tb1_from_db1.employee_code = tb1_from_db2.cms_user " & _
"AND tb2_from_db2.sub_task_id = tb1_from_db2.sub_task_id " & _
"AND len(tb1_from_db1.employee_ code) = 3 " & _
"AND tb1_from_db2.inactive = 0 " & _
"AND tb2_from_db2.inactive = 0 " & _
"AND tb1_from_db1._leaver = 'n' " & _
"AND tb1_from_db2.email_sender = 1 " & _
"AND tb1_from_db1.employee_code = 'narmi' " & _
"AND tb2_from_db2.sub_task_url = '../pages/intro.aspx'", objConnection)
objDataSet = New DataSet()
objSelectDataAdapter.Fill( objDataSet , "DSEmails")
Response.Write("URL: " & TestURL & "<br />")
Response.Write("EMP: " & xemp_code)
TextBox1.Text = objDataSet.Tables("DSEmail s").Column s("email") .ColumnNam e.ToString ()
End Sub
'-------------THE CODE ENDS HERE---------------
URGENT 500 Points!
Thanks
I'm having problems with this sub. When i run the sql query in this sub in query analyser, it returns 1 email e.g. narmi@home.com
But when I run the following sub on page load of my webform, it only returns the word "email" in the textbox1.
Anyone know why this is happening?
'-------------THE CODE STARTS HERE---------------
Sub EmailSender()
Dim xCN As String = Request.ServerVariables("L
Dim xllength As Integer = xCN.Length
Dim xemp_code As String = xCN.Substring(xllength - 3, 3)
Dim TestURL As String = "../employees/basic_detail
objSelectDataAdapter = New SqlDataAdapter("SELECT CASE WHEN tb2_from_db1.internet_addr
"lower(tb2_from_db1.first_
"WHEN tb2_from_db1.internet_addr
"lower(tb2_from_db1.first_
"ELSE lower(tb2_from_db1.interne
"END As [email] " & _
"FROM db1.dbo.hbm_persnl tb1_from_db1, " & _
"db1.dbo.hbm_name tb2_from_db1, " & _
"db2.dbo.ps_tb1_from_db2_e
"db2.dbo.ps_task_sub(tb2_f
"WHERE(tb1_from_db1.name_u
"AND tb1_from_db1.employee_code
"AND tb2_from_db2.sub_task_id = tb1_from_db2.sub_task_id " & _
"AND len(tb1_from_db1.employee_
"AND tb1_from_db2.inactive = 0 " & _
"AND tb2_from_db2.inactive = 0 " & _
"AND tb1_from_db1._leaver = 'n' " & _
"AND tb1_from_db2.email_sender = 1 " & _
"AND tb1_from_db1.employee_code
"AND tb2_from_db2.sub_task_url = '../pages/intro.aspx'", objConnection)
objDataSet = New DataSet()
objSelectDataAdapter.Fill(
Response.Write("URL: " & TestURL & "<br />")
Response.Write("EMP: " & xemp_code)
TextBox1.Text = objDataSet.Tables("DSEmail
End Sub
'-------------THE CODE ENDS HERE---------------
URGENT 500 Points!
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My pleasure!
ASKER