ahsan ashfaq

ahsan ashfaq

  • NA
  • 14
  • 0

odbc connection

Dec 4 2009 7:16 AM
public DataSet FillContact(string mcid)
        {
            DataSet ds = new DataSet();
            OdbcDataAdapter da = new OdbcDataAdapter();
            query = "Select formid,FIELDID,NOID,TEXT from contacts where formid='"+ mcid +"'";
            OdbcCommand cmdc = new OdbcCommand(query);

            using (OdbcConnection connc = new OdbcConnection(connstring))
            {
                cmdc.Connection = connc;
                connc.Open();
                da.SelectCommand = cmdc;
                da.Fill(ds, "Contacts");
                return ds;
            }

                
        }

this is the function i use to return dataset
now what i m preplexed about is
i am using odbc connection by using keyword
my 2 questions are
will using automatically close the connection when it's scoped out?(Query normally executed)
will using still automatically closes the connection when it encounters the problem in any of the code before return ds;

Answers (1)