You have a Public constructor that takes in the values X and Y, implying that you would be creating an instance of this classNot sure why your variables and the boundary method need to be static, unless I am missing to see something.
But still the values would be set, upon initializing, it would only behave differently. Can you post the code where you are actually calling this class? On Tue, Jan 20, 2009 at 3:56 PM, Chris <[email protected]> wrote: > > Hi all, > > Very new to this game so Im probably making a simple yet fundamental > mistake. > > Im trying to pass into C# (2008 Express) 2 (float) variables from > another program, and use these to kick off a stroed proc on a server. > The server end of things is fine, but Im struggling to get the > variables to pass in. Its either the way Im declaring and setting the > variables, or the way im building the .dll file. I need the .dll file > as I have another program which calls C# with the variables. Any > Ideas? > > Thanks in advance > > Chris > > using System; > using System.Collections.Generic; > using System.Text; > using System.Data; > using System.Data.SqlClient; > > namespace ExecuteStoredProcedure > { > public class Program > { > private static double dLong; > private static double dLat; > > public Program(double X, float Y) > { > dLong = X; > dLat = Y; > } > > //static void Main(string[] args) > public static void Boundary() > { > > SqlConnection conn = new SqlConnection(); > try > { > conn.ConnectionString = "integrated security=SSPI;data > source=ServerName;" + > "persist security info=False;initial > catalog=DatabaseName"; > conn.Open(); > Console.WriteLine("Connection successful"); > } > catch (Exception ex) > { > Console.WriteLine(ex.Message); > return; > } > > SqlCommand db_cmd = new SqlCommand("dbo.uspStoredProc", > conn); > db_cmd.CommandType = CommandType.StoredProcedure; > db_cmd.Parameters.Add(new SqlParameter("@X", > ExecuteStoredProcedure.Program.dLong)); > db_cmd.Parameters.Add(new SqlParameter("@Y", > ExecuteStoredProcedure.Program.dLat)); > try > { > db_cmd.ExecuteNonQuery(); > Console.WriteLine("Data write successful"); > Console.Read(); > } > catch { Console.WriteLine("Error"); } > conn.Close(); > } > } > } > -- Kaarthik, http://coding-passion.blogspot.com
