I am in the process of teaching myself the C# language and running into issues. As simple and ridiculous as this sounds I can't seem to call a function. I have created a class for all my DB function. Here is what it looks like:
Now, I have a Windows Form in which I want to call the function dbConn() and I'm just not sure how to do it. I've tried googling it and not finding exactly what I'm looking for. Looking at the code above, if you know of a more efficient way to do this...I'm all ears!!!Code:using System; using System.Data.Sql; using System.Data.SqlClient; using System.Collections.Generic; using System.Linq; using System.Text; namespace WindowsFormsApplication1 { class DBUtilities { public SqlConnection dbConn() { SqlConnection cnn = new SqlConnection("Data Source=MCK\\MCKEXPRESS;Initial Catalog=myDataBase;Integrated Security=SSPI;"); if (cnn == null && cnn.State == System.Data.ConnectionState.Open) { cnn.Open(); } return cnn; } } }
Thanks,


Reply With Quote
