update data?
-
i have 2 following solution the first
sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
SqlCommand1.ExecuteNonQuery()the second
'fill into datagridview
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.SelectCommand = SqlCommand1
SqlDataAdapter1.Fill(DataSet1, "customers")
DataGridView1.DataSource = DataSet1
DataGridView1.DataMember = "customers"'add new row into datatable
row = DataSet1.Tables("customers").NewRow()
row.Item(0) = "firstName"
row.Item(1) = "lastName"
row.Item(2) = "phone"
DataSet1.Tables("customers").Rows.Add(row)'update data
SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
SqlDataAdapter1.Update(DataSet1, "customers")Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!
-
i have 2 following solution the first
sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
SqlCommand1.ExecuteNonQuery()the second
'fill into datagridview
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.SelectCommand = SqlCommand1
SqlDataAdapter1.Fill(DataSet1, "customers")
DataGridView1.DataSource = DataSet1
DataGridView1.DataMember = "customers"'add new row into datatable
row = DataSet1.Tables("customers").NewRow()
row.Item(0) = "firstName"
row.Item(1) = "lastName"
row.Item(2) = "phone"
DataSet1.Tables("customers").Rows.Add(row)'update data
SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
SqlDataAdapter1.Update(DataSet1, "customers")Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!
These two are doing different things, You cant Compare them. I suggest you buy a Book
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/
-
i have 2 following solution the first
sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
SqlCommand1.ExecuteNonQuery()the second
'fill into datagridview
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.SelectCommand = SqlCommand1
SqlDataAdapter1.Fill(DataSet1, "customers")
DataGridView1.DataSource = DataSet1
DataGridView1.DataMember = "customers"'add new row into datatable
row = DataSet1.Tables("customers").NewRow()
row.Item(0) = "firstName"
row.Item(1) = "lastName"
row.Item(2) = "phone"
DataSet1.Tables("customers").Rows.Add(row)'update data
SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
SqlDataAdapter1.Update(DataSet1, "customers")Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!
I see a lot of this. Clearly the first is better etc. Why bother filling a dataset in order to perform an insert? The second option will produce the same SQL at the end of the day, but at high cost in processing to generating something you can type yourself in seconds.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
-
i have 2 following solution the first
sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
SqlCommand1.ExecuteNonQuery()the second
'fill into datagridview
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.SelectCommand = SqlCommand1
SqlDataAdapter1.Fill(DataSet1, "customers")
DataGridView1.DataSource = DataSet1
DataGridView1.DataMember = "customers"'add new row into datatable
row = DataSet1.Tables("customers").NewRow()
row.Item(0) = "firstName"
row.Item(1) = "lastName"
row.Item(2) = "phone"
DataSet1.Tables("customers").Rows.Add(row)'update data
SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
SqlCommand1.CommandText = "select * from customers "
SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
SqlDataAdapter1.Update(DataSet1, "customers")Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!
The first one is a little better than the second b/c your using a bit more processing power on your app server to create the dataset you have on the second. In the first, most of the processing will be performed on the database server which is optimized for doing such computations.
Plecco Technologies, Inc. Web Design | Software Development | Internet Marketing
modified on Wednesday, January 27, 2010 10:01 AM