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();
        }
    }
}

Reply via email to