sqldataadapter

connected model and disconnected model in EF

百般思念 提交于 2019-11-30 01:16:37
问题 I'm confused a lot about connected model and disconnected in entity framework . I was using traditional ADO.net ( DataReader for connected model and DataAdapter for disconnected model) and all I know that I use connected model when I have many users need to update or insert together and the disconnected model in a few circumstances when I need to send the data to other process make some operations on the data in memory and send them back to the db . Now I read some articles about connected

SqlDataReader vs SqlDataAdapter: which one has the better performance for returning a DataTable?

蓝咒 提交于 2019-11-29 22:20:35
I want to know which one has the better performance for returning a DataTable . Here for SqlDataReader I use DataTable.Load(dr) Using SqlDataReader : public static DataTable populateUsingDataReader(string myQuery) { DataTable dt = new DataTable(); using (SqlConnection con = new SqlConnection(constring)) { SqlCommand cmd = new SqlCommand(myQuery, con); con.Open(); SqlDataReader dr = null; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { dt.Load(dr); } return dt; } } using SqlDataAdapter : public DataTable populateUsingDataAdapter(string myQuery) { SqlDataAdapter dap =

SqlDataReader vs SqlDataAdapter: which one has the better performance for returning a DataTable?

跟風遠走 提交于 2019-11-28 19:53:30
问题 I want to know which one has the better performance for returning a DataTable . Here for SqlDataReader I use DataTable.Load(dr) Using SqlDataReader : public static DataTable populateUsingDataReader(string myQuery) { DataTable dt = new DataTable(); using (SqlConnection con = new SqlConnection(constring)) { SqlCommand cmd = new SqlCommand(myQuery, con); con.Open(); SqlDataReader dr = null; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { dt.Load(dr); } return dt; } }

DataTable from TextFile?

梦想与她 提交于 2019-11-28 11:39:44
I have taken over an application written by another developer, which reads data from a database, and exports it. The developer used DataTables and DataAdaptors. So, _dataAdapter = new SqlDataAdapter("Select * From C....", myConnection); and then ExtractedData = new DataTable("CreditCards"); _dataAdapter.Fill(ExtractedData); ExtractedData is then passed around to do different functions. I have now been told that I need to, in addition to this, get the same format of data from some comma separated text files. The application does the same processing - it's just getting the data from two sources.

Data Adapter Vs Sql Command

随声附和 提交于 2019-11-28 10:23:10
Which one would be better in executing an insert statement for ms-sql database: Sql DataAdapter or SQL Command Object? Which of them would be better, while inserting only one row and while inserting multiple rows ? A simple example of code usage: SQL Command string query = "insert into Table1(col1,col2,col3) values (@value1,@value2,@value3)"; int i; SqlCommand cmd = new SqlCommand(query, connection); // add parameters... cmd.Parameters.Add("@value1",SqlDbType.VarChar).Value=txtBox1.Text; cmd.Parameters.Add("@value2",SqlDbType.VarChar).Value=txtBox2.Text; cmd.Parameters.Add("@value3",SqlDbType

DataTable from TextFile?

吃可爱长大的小学妹 提交于 2019-11-27 06:25:31
问题 I have taken over an application written by another developer, which reads data from a database, and exports it. The developer used DataTables and DataAdaptors. So, _dataAdapter = new SqlDataAdapter("Select * From C....", myConnection); and then ExtractedData = new DataTable("CreditCards"); _dataAdapter.Fill(ExtractedData); ExtractedData is then passed around to do different functions. I have now been told that I need to, in addition to this, get the same format of data from some comma

Data Adapter Vs Sql Command

馋奶兔 提交于 2019-11-27 03:34:26
问题 Which one would be better in executing an insert statement for ms-sql database: Sql DataAdapter or SQL Command Object? Which of them would be better, while inserting only one row and while inserting multiple rows ? A simple example of code usage: SQL Command string query = "insert into Table1(col1,col2,col3) values (@value1,@value2,@value3)"; int i; SqlCommand cmd = new SqlCommand(query, connection); // add parameters... cmd.Parameters.Add("@value1",SqlDbType.VarChar).Value=txtBox1.Text; cmd

c# Using Parameters.AddWithValue in SqlDataAdapter

依然范特西╮ 提交于 2019-11-26 20:42:29
How can I use Parameters.AddWithValue with an SqlDataAdapter. Below searching codes. var da = new SqlDataAdapter("SELECT * FROM annotations WHERE annotation LIKE '%"+txtSearch.Text+"%'", _mssqlCon.connection); var dt = new DataTable(); da.Fill(dt); I rewrote the code like this: SqlDataAdapter da; da = new SqlDataAdapter("SELECT * FROM annotations WHERE annotation LIKE '%@search%'", _mssqlCon.connection); da.SelectCommand.Parameters.AddWithValue("@search",txtSearch.Text); var dt = new DataTable(); da.Fill(dt); but it failed. The string used to initialize the SqlDataAdapter becomes the