Skip to content

Problem calling my code

franck meloni

Asked Jun 19, 2012, 12:37 PM EDT2 answers
Share
LinkedInX
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.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Sorry, It tell me that SQLCommandInsert is a method but is used as a type.

    Also, if anyone can suggest me good article or books on OOP, it would be greatly appreciated.
    0
  • 1 short reply
    • Suthish Nair
      0
      what error you are getting..
      0