[Solved] Best Approach For CRUD [closed]

You certainly can. It surely will vary from one provider to another. You can take a peek into how MySql .Net Connector is implemented over here. This raises the question, why would you want to do that? Providers give you a standard API your application can depend on. That allows you to switch a provider … Read more

[Solved] How to use Select method of DataTable

Yes, this works. For a list of all possible expressions see http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx Here also is a sample program demonstrating this works. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { DataTable table = new DataTable(); // Create the first column. DataColumn textColumn = … Read more

[Solved] Performance issue with this code [closed]

In short: You should create,open,use,close,dispose Connections where you’re using them. The best way is to use the using-statement. By not closing the connection as soon as possible, the Connection-Pool needs to create new physical connections to the dbms which is very expensive in terms of perfomance. Using conn As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings(“ConnStr”).ConnectionString) Using insertCommand As New … Read more

[Solved] Exception in web login form processing in Visual Studio 2012

You aren’t setting the SqlCommand‘s connection. Change your constructor to include the connection. SqlCommand cmd = new SqlCommand(“SELECT * FROM t304_users WHERE userName = @UserName AND password = @Password”, conn); The way you had it, there was no association between the SqlCommand and the SqlConnection. I also fixed your syntax as suggested in a comment … Read more

[Solved] Trouble writing a select query [closed]

It looks like vb code if you want c# code then use following code cmd = new SqlCommand(“select name from wq where id='” + TextBox1.Text + “‘”, con); con.Open(); dr = cmd.ExecuteReader(); dr.Read(); TextBox2.Text = dr[0].ToString(); dr.Close(); con.Close(); 7 solved Trouble writing a select query [closed]

[Solved] class that gets a value from database [closed]

public static class myMethods { public static string getName(){ string name = “”; ConnectionStringSettings myConnectionString = ConfigurationManager.ConnectionStrings[“LibrarySystem.Properties.Settings.LibraryConnectionString”]; using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString)) { myDatabaseConnection.Open(); using (SqlCommand mySqlCommand = new SqlCommand(“select Top 1 * from Setting Order By SettingID Desc”, myDatabaseConnection)) using (SqlDataReader sqlreader = mySqlCommand.ExecuteReader()) { if (sqlreader.Read()) { name = sqlreader[“Name”].ToString(); } } … Read more