baxtalo
asked on
Connection String for Teradata in Classic ASP versus .NET
Hi Experts,
I'm trying to make this script work when I save the file with .aspx extension.
The first part of the script captures the logged in person's login ID, and the second part matches it with his Emp_Id, First and Last name, then displays this info on the page.
It's working perfectly when I use Classic ASP and save the file with .asp extension.
Can anyone please walk me through the process of converting it to .NET and make it work with .aspx extension?
Thank you
I'm trying to make this script work when I save the file with .aspx extension.
The first part of the script captures the logged in person's login ID, and the second part matches it with his Emp_Id, First and Last name, then displays this info on the page.
It's working perfectly when I use Classic ASP and save the file with .asp extension.
Can anyone please walk me through the process of converting it to .NET and make it work with .aspx extension?
Thank you
<%
If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End
End If
%>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=Teradata;DRIVER={Teradata};UID=MyUID;PWD=MyPWD;Persist Security Info=True;"
set rs = Server.CreateObject("ADODB.recordset")
Dim UserID
UserID = Request.ServerVariables("LOGON_USER")
'if always 3 character User ID with '\'
UserID = Mid(UserID, 5)
rs.Open "SELECT First_Name, Last_Name, Emp_Id FROM PhoneBook WHERE Emp_Id = '" & UserID & "'", conn
do until rs.EOF
First_Name = rs("First_Name")
Last_Name = rs("Last_Name")
Emp_Id = rs("Emp_Id")
rs.MoveNext
loop
rs.close
conn.close
%>
<%=First_Name%> <%=Last_Name%> <%=Emp_Id%>
A literal translation to VB.Net would be something like:
Assuming that the TeraData driver is odbc. To display the values you would normally assign them to control properties rather than just dumping them to the browser too.
If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End()
End If
Dim UserID As String = Request.ServerVariables("LOGON_USER")
'if always 3 character User ID with '\'
UserID = Mid(UserID, 5)
Dim conn As Odbc.OdbcConnection = New Odbc.OdbcConnection("DSN=Teradata;DRIVER={Teradata};UID=MyUID;PWD=MyPWD;Persist Security Info=True;")
Dim cmd As Odbc.OdbcCommand = New Odbc.OdbcCommand("SELECT First_Name, Last_Name, Emp_Id FROM PhoneBook WHERE Emp_Id = '" & UserID & "'", conn)
conn.Open()
Dim reader As Odbc.OdbcDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
'// assuming you're only expecting one result
If reader.Read() Then
First_Name = reader.GetString(reader.GetOrdinal("First_Name"))
Last_Name = reader.GetString(reader.GetOrdinal("Last_Name"))
Emp_Id = reader.GetInt32(reader.GetOrdinal(("Emp_Id"))
End If
Assuming that the TeraData driver is odbc. To display the values you would normally assign them to control properties rather than just dumping them to the browser too.
ASKER
I'm absolutely new at VB.Net
How do I make this into a web page? Where do I need to put the brackets?
If I save it the way it is now the browser displays it as plain text.
Thanks
How do I make this into a web page? Where do I need to put the brackets?
If I save it the way it is now the browser displays it as plain text.
Thanks
ASKER
I dont' have Visual Studio, I'm just using Notepad to write my code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. I thought that it can be done using Notepad. Until now I coded classic ASP only, and I've never used WYSIWYG editors. I always liked writing the code of my pages myself in TextPad.
I guess I will have to learn using Visual Studio. Can you recommend any books, or web sites that could help me learn using .NET very quickly?
I really appreciate your help.
I guess I will have to learn using Visual Studio. Can you recommend any books, or web sites that could help me learn using .NET very quickly?
I really appreciate your help.
ASKER
Great, thank you!
ASKER
Compiler Error Message: BC30807: 'Let' and 'Set' assignment statements are no longer supported.
I don't know how to correct it, and what to use instead of Set in my connection string