|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB to C#I need to convert the select statement below from VB ASP to C# ASP.NET. Pls. help and thanks in advance. ' Create recordset and query Set rsCHI = Server.CreateObject("ADODB.Recordset") sCHI = "SELECT a.cust_des1, a.des1 projectName, b.job_no JobNo, b.des1 jobName, b.contract_amt, " _ & "b.est_start_date,b.est_completion_date " _ & "FROM pa_project_master a, pa_job b " _ & "WHERE b.project_no = '" & Request("projectNo") & "' " _ & " And a.project_no = b.project_no " _ & " And b.job_no in (select job_no from pa_security where emp_no = '" & Session("userempno") & "' "_ & " And project_no= '" & Request("projectNo") & "')" ' Open recordset and run query rsCHI.Open sCHI,db,,,adCmdText If rsCHI.EOF Then Response.Redirect("donf.asp") End if Response.Expires = 0 ' Set customer session variable Session("customer") = rsCHI("cust_des1") detailJobNo = rsCHI("jobNo") Go to http://www.google.com
Type in VB.NET C# & press enter. I am sure you will find an online convertor there. That's why they are there Newbie,
Because of the fact that the result will be C# code, is the newsgroup microsoft.public.dotnet.languages.csharp a much better place for this question. Altough that you will get a good answer is not so likely because you are using ADODB "recordset" code what is not so much used with dotNet. While you as well use a Select string that is agains most rules. However I think that you can better try it there. Cor C# does not require line continuation like VB does. You don't have to
convert the SQL statement, you need to change syntax. So lets say for example you had this: sCHI = "SELECT a.cust_des1, a.des1 projectName, b.job_no JobNo, b.des1, " & _ "jobName, b.contract_amt FROM SomeTable" In C#, you can do this: sCHI = @"SELECT a.cust_des1, a.des1 projectName, b.job_no JobNo, b.des1 jobName, b.contract_amt FROM SomeTable"; Of course, your code appears to have a shortcut to setting the object sCHI equal to a string (which is actually setting it to the default property of the ADO Recordset) . Try to avoid this and explicitly assign the appropriate property. Also, the line continuation is the least of your worries. You should use ADO.NET objects instead of classic ADO. In ASP.NET the Request , Response and Session objects are still available to you, but use them wisely, in particularly , Session. My strongest recommendation for you is to go to msdn.microsoft.com and read up on best practices for ADO.NET and ASP.NET. Good Luck Vinny Davi MCSD.NET
FileSystemObject vs System.IO.File
compression of a string , but must be interoptable someone an idea ?? Array of Hash Tables Query database in VB.NET Problems with the PrintPreviewControl, PrintPreviewDialog controls [String] Create ListView columns dynamically from XML C# to VB Set Desktop Progress Bar |
|||||||||||||||||||||||