Your strSQL string does not contain Visual Basic code; it contains T-SQL code as this is the WHERE clause for an SQL query. Thus, since this is for SQL Server and not your actual program, no conversion is necessary.
Christopher Reed, MCT, MCPD, MCTS, Microsoft Specialist, MTA
"The oxen are slow, but the earth is patient."
I removed the strSql. This variable been used in program as a string variable in classic visual basic code and used for concatination. Please ignore that help me with the rest of the Math function code conversion.
My point is that the functions you list are T-SQL functions, not Visual Basic.
So, are you still using a WHERE clause? If not, then are you trying to do this functionality in C# directly? If this is the case, then we could try to proceed with your "conversions".
Christopher Reed, MCT, MCPD, MCTS, Microsoft Specialist, MTA
"The oxen are slow, but the earth is patient."
Yes i am appending them in C# and passing them as sql string (Ex:- sqlStr) along with where clause to database. Since lot of dynamic sql is there, so i am using
CommandType.Text
than CommandType.StoredProcedure.
So according i can pass them as it is as these are T-SQL functions. I need not convert them using System.Math library of C#. Am i correct or am i missing something here?
Your are correct. If you are passing the actual SQL statement, then you do not need to use any C#/.NET methods in your statement. Everything should work with T-SQL.
Note, of course, that the ampersands (&) need to replaced with plus (+) signs.
Christopher Reed, MCT, MCPD, MCTS, Microsoft Specialist, MTA
"The oxen are slow, but the earth is patient."
ThotaAshok
Member
26 Points
139 Posts
Need help to use Math functions of classic visual basic to c#.
Sep 15, 2011 05:15 PM|LINK
I have a classic vb code which i need to convert to C#. Could somebody help me?
" where 1.15077*60*degrees(acos((sin(radians(" & orgLat & "))*sin(radians(latnorth)))+(cos(radians(" & orgLat & "))*cos(radians(latnorth))*cos(radians(" & orgLong & ")-radians(longwest))))) < " & pstrOrgMiles & ")"
My Starting approach for ==> degrees(acos((sin(radians(" + orgLatitude + ")) ==> is as follows:-
double firstPart = 0.0;
firstPart = Math.Acos(Math.Sin(Convert.ToDouble(orgLatitude))) * (180 / Math.PI);
Thank You.
Careed
All-Star
18764 Points
3637 Posts
Re: Need help to use Math functions of classic visual basic to c#.
Sep 15, 2011 05:30 PM|LINK
Your strSQL string does not contain Visual Basic code; it contains T-SQL code as this is the WHERE clause for an SQL query. Thus, since this is for SQL Server and not your actual program, no conversion is necessary.
"The oxen are slow, but the earth is patient."
ThotaAshok
Member
26 Points
139 Posts
Re: Need help to use Math functions of classic visual basic to c#.
Sep 15, 2011 06:06 PM|LINK
I removed the strSql. This variable been used in program as a string variable in classic visual basic code and used for concatination. Please ignore that help me with the rest of the Math function code conversion.
Careed
All-Star
18764 Points
3637 Posts
Re: Need help to use Math functions of classic visual basic to c#.
Sep 15, 2011 06:16 PM|LINK
My point is that the functions you list are T-SQL functions, not Visual Basic.
So, are you still using a WHERE clause? If not, then are you trying to do this functionality in C# directly? If this is the case, then we could try to proceed with your "conversions".
"The oxen are slow, but the earth is patient."
ThotaAshok
Member
26 Points
139 Posts
Re: Need help to use Math functions of classic visual basic to c#.
Sep 15, 2011 07:04 PM|LINK
Yes i am appending them in C# and passing them as sql string (Ex:- sqlStr) along with where clause to database. Since lot of dynamic sql is there, so i am using CommandType.Text than CommandType.StoredProcedure. So according i can pass them as it is as these are T-SQL functions. I need not convert them using System.Math library of C#. Am i correct or am i missing something here?
using
(SqlConnection connection = new SqlConnection(dbConnectionString))
{
command =
new SqlCommand();
command.CommandType =
CommandType.Text;
command.Connection = connection;
command.CommandTimeout = 120;
command.CommandText = sqlStr;
connection.Open();
....
.....
}
Thank You
Ashok
Actual string is as follows:-
strSQL = strSQL & " where 1.15077*60*degrees(acos((sin(radians(" & orgLat & "))*sin(radians(latnorth)))+(cos(radians(" & orgLat & "))*cos(radians(latnorth))*cos(radians(" & orgLong & ")-radians(longwest))))) < " & pstrOrgMiles
Careed
All-Star
18764 Points
3637 Posts
Re: Need help to use Math functions of classic visual basic to c#.
Sep 15, 2011 08:25 PM|LINK
Your are correct. If you are passing the actual SQL statement, then you do not need to use any C#/.NET methods in your statement. Everything should work with T-SQL.
Note, of course, that the ampersands (&) need to replaced with plus (+) signs.
"The oxen are slow, but the earth is patient."