franck meloni

franck meloni

  • NA
  • 3
  • 1.8k

problem calling my code

Jun 19 2012 4:37 PM
hi, I'm new in the c# world and i have a lot to learn.

What I'm trying to do is to call this code from another file.

I tried doing so by writing  SQLDataConnections . DataConnections . SQLCommandInsert ("The SQL command here");

I'm using visual studio 2010 to make a website on azure.

Any other hint as to help me understand c# better will be greatly appreciated.



**********************************************************************

namespace SQLDataConnections
{
        public static class DataConnections
        {
                    public static Boolean SQLCommandInsert(string InsertCommandString)
                {
                        SqlConnection thisConnection = new SqlConnection("ConnectionString");
                        SqlDataAdapter da  = new SqlDataAdapter();
                        da.InsertCommand = new SqlCommand(InsertCommandString, thisConnection);


                        thisConnection.Open();
                        da.InsertCommand.ExecuteNonQuery();
                        thisConnection.Close();
                    return true;
                }


                public static Boolean SQLCommandDelete(string DeleteCommandString)
                {
                        SqlConnection thisConnection = new SqlConnection("ConnectionString");
                        SqlDataAdapter da  = new SqlDataAdapter();
                        da.DeleteCommand = new SqlCommand(DeleteCommandString, thisConnection);


                        thisConnection.Open();
                        da.DeleteCommand.ExecuteNonQuery();
                        thisConnection.Close();
                    return true;
                }


                    public static Boolean SQLCommandSelect(string SelectCommandString)
                {
                        SqlConnection thisConnection = new SqlConnection("ConnectionString");
                        SqlDataAdapter da  = new SqlDataAdapter();
                        da.SelectCommand = new SqlCommand(SelectCommandString, thisConnection);


                        thisConnection.Open();
                        da.SelectCommand.ExecuteNonQuery();
                        thisConnection.Close();
                    return true;
                }


                    public static Boolean SQLCommandUpdate(string UpdateCommandString)
                {
                        SqlConnection thisConnection = new SqlConnection("ConnectionString");
                        SqlDataAdapter da  = new SqlDataAdapter();
                        da.UpdateCommand = new SqlCommand(UpdateCommandString, thisConnection);


                        thisConnection.Open();
                        da.UpdateCommand.ExecuteNonQuery();
                        thisConnection.Close();
                    return true;
                }
        }
}
*************************************************************************

If anyone can tell me how to put the code in spoiler I could edit my post to do so.


Attachment: code sql.zip

Answers (2)