{"id":91,"date":"2014-05-15T20:26:00","date_gmt":"2014-05-15T19:26:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/15\/datamanger\/"},"modified":"2014-05-15T20:26:00","modified_gmt":"2014-05-15T19:26:00","slug":"datamanger","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/15\/datamanger\/","title":{"rendered":"DataManger?"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>2 Minute, 19 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n&nbsp;public class DataManager<br \/>\n&nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; string connectionString = &#8220;Data Source=(local);Initial Catalog=CompanyDb;Persist Security Info=True;User ID=sa;Password=123&#8221;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; public int SqlExecuteQuery(string strQuery, int timeOut)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int returnCount = 0;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlConnection sqlConnection = new SqlConnection();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlCommand sqlCommand = new SqlCommand();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.ConnectionString = connectionString;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.Open();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.CommandText = strQuery;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.CommandTimeout = timeOut;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.Connection = sqlConnection;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnCount = sqlCommand.ExecuteNonQuery();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.Close();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return returnCount;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; public DataSet SqlSelectQuery(string strQuery, int timeOut)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataSet ds = new DataSet();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlConnection sqlConnection = new SqlConnection();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlCommand sqlCommand = new SqlCommand();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.ConnectionString = connectionString;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.Open();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.CommandText = strQuery;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.CommandTimeout = timeOut;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.Connection = sqlConnection;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlDataAdapter.Fill(ds);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.Close();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ds;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; public object SqlScalarQuery(string strQuery, int timeOut)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; object returnString = new object();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlConnection sqlConnection = new SqlConnection();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlCommand sqlCommand = new SqlCommand();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.ConnectionString = connectionString;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.Open();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.CommandText = strQuery;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.CommandTimeout = timeOut;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlCommand.Connection = sqlConnection;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnString = sqlCommand.ExecuteScalar();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlConnection.Close();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return returnString;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; }<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nTo generate Max Id<\/p>\n<p>&nbsp; &nbsp;public void GetStudentId()<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string str = &#8220;select isnull(max(id),0)+1 from student&#8221;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TextBox6.Text = Convert.ToString(dm.SqlScalarQuery(str, 1000));<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;public class DataManager &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; string connectionString = &#8220;Data Source=(local);Initial Catalog=CompanyDb;Persist Security Info=True;User ID=sa;Password=123&#8221;; &nbsp; &nbsp; &nbsp; &nbsp; public int SqlExecuteQuery(string strQuery, int timeOut) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int returnCount = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlConnection sqlConnection = new SqlConnection(); [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-blog"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"&nbsp;public class DataManager &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; string connectionString = &#8220;Data Source=(local);Initial Catalog=CompanyDb;Persist Security Info=True;User ID=sa;Password=123&#8221;; &nbsp; &nbsp; &nbsp; &nbsp; public int SqlExecuteQuery(string strQuery, int timeOut) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int returnCount = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlConnection sqlConnection = new SqlConnection();&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/91"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}