Search:
Namespaces
Discussions
.NET v1.1
Feedback
SqlCommandBuilder question
Messages
Related Types
This message was discovered on
ASPFriends.com 'ngfx-sqlclient' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Bob Herrmann
-- Moved from [aspngdata] to [ngfx-sqlclient] by Sheik Yerbouti <
Click here to reveal e-mail address
> --
Hi all,
I recently copied a snippet of code from a .Net web site which helped me convert a XML file to SQL. The code does work as planned. I notice this code uses a feature which I have not used before, specifically the
SqlCommandBuilder
. I have listed the code below. This code does the INSERT into my SQL database. My question is the how the heck does it do this? I do not see where the INSERT command is used in the SqlCOmmandBuilder object. Can someone explain how this works so that I can understand it? I'd also like to know how this could be modified to use the UPDAT and DELETE commands.
Bob
Private Function InsertXMLIntoDatabase(ByVal ds As DataSet) As Boolean
Dim connStr As String = "server=abc;uid=sa;pwd=pass;database=BobMS"
Dim sql As String = "SELECT * FROM tabTopFolder"
Dim insertStatus As Boolean = True
Dim dataConn As New
SqlConnection
(connStr)
Dim da As New
SqlDataAdapter
(sql, dataConn)
Dim cb As New
SqlCommandBuilder
(da)
Try
da.Update(ds, "tabTopFolder")
Catch exp As Exception
Response.Write("<br> " & exp.Message)
insertStatus = False
Finally
If dataConn.State <>
ConnectionState
.Closed Then
dataConn.Close()
End If
End Try
Return insertStatus
End Function 'InsertXMLIntoDatabase
Reply to this message...
William \(Bill\) Vaughn (VIP)
The CommandBuilder class takes the SELECT statement from the
DataAdapter
SelectCommand, parses it and makes a round trip to the server asking the
provider (and server) to describe the SQL. From that it congers the
UPDATE, INSERT and DELETE action queries and populates the
DataAdapter
commands appropriately.
hth
William (Bill) Vaughn
Author, trainer, mentor
Microsoft Regional Director -- Pacific Northwest
Beta V Corporation
Redmond, Washington USA
www.betav.com
(425) 556-9205 (v/f)
-----Original Message-----
From: Bob Herrmann [mailto:
Click here to reveal e-mail address
]
Sent: Friday, July 26, 2002 6:56 AM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient]
SqlCommandBuilder
question
-- Moved from [aspngdata] to [ngfx-sqlclient] by Sheik Yerbouti
<
Click here to reveal e-mail address
> --
Hi all,
I recently copied a snippet of code from a .Net web site which helped me
convert a XML file to SQL. The code does work as planned. I notice
this code uses a feature which I have not used before, specifically the
SqlCommandBuilder
. I have listed the code below. This code does the
INSERT into my SQL database. My question is the how the heck does it do
this? I do not see where the INSERT command is used in the
SqlCOmmandBuilder object. Can someone explain how this works so that I
can understand it? I'd also like to know how this could be modified to
use the UPDAT and DELETE commands.
Bob
Private Function InsertXMLIntoDatabase(ByVal ds As DataSet) As Boolean
Dim connStr As String = "server=abc;uid=sa;pwd=pass;database=BobMS"
Dim sql As String = "SELECT * FROM tabTopFolder"
Dim insertStatus As Boolean = True
Dim dataConn As New
SqlConnection
(connStr)
Dim da As New
SqlDataAdapter
(sql, dataConn)
Dim cb As New
SqlCommandBuilder
(da)
Try
da.Update(ds, "tabTopFolder")
Catch exp As Exception
Response.Write("<br> " & exp.Message)
insertStatus = False
Finally
If dataConn.State <>
ConnectionState
.Closed Then
dataConn.Close()
End If
End Try
Return insertStatus
End Function 'InsertXMLIntoDatabase
| [ngfx-sqlclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp
= JOIN/QUIT
Reply to this message...
Dan Wahlin
Also...it's quite convenient to use in some circumstances (and I'll use
it for more simple apps) but due to the round trip Bill mentioned it's
not as efficient as defining everything yourself. I saw a presentation
at Tech Ed by Michael Pizzo (Microsoft ADO.NET software architect) and
he basically said that if you want to maximize your performance don't
use it (which of course makes sense based upon Bill's statement).
Dan
Wahlin Consulting LLC
Microsoft MVP - ASP.NET
http://www.XMLforASP.NET
XML for ASP.NET Developers by Dan Wahlin in bookstores everywhere!
-----Original Message-----
From: William (Bill) Vaughn [mailto:
Click here to reveal e-mail address
]
Sent: Friday, July 26, 2002 12:36 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] RE:
SqlCommandBuilder
question
The CommandBuilder class takes the SELECT statement from the
DataAdapter
SelectCommand, parses it and makes a round trip to the server asking the
provider (and server) to describe the SQL. From that it congers the
UPDATE, INSERT and DELETE action queries and populates the
DataAdapter
commands appropriately.
hth
William (Bill) Vaughn
Author, trainer, mentor
Microsoft Regional Director -- Pacific Northwest
Beta V Corporation
Redmond, Washington USA
www.betav.com
(425) 556-9205 (v/f)
-----Original Message-----
From: Bob Herrmann [mailto:
Click here to reveal e-mail address
]
Sent: Friday, July 26, 2002 6:56 AM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient]
SqlCommandBuilder
question
-- Moved from [aspngdata] to [ngfx-sqlclient] by Sheik Yerbouti
<
Click here to reveal e-mail address
> --
Hi all,
I recently copied a snippet of code from a .Net web site which helped me
convert a XML file to SQL. The code does work as planned. I notice
this code uses a feature which I have not used before, specifically the
SqlCommandBuilder
. I have listed the code below. This code does the
INSERT into my SQL database. My question is the how the heck does it do
this? I do not see where the INSERT command is used in the
SqlCOmmandBuilder object. Can someone explain how this works so that I
can understand it? I'd also like to know how this could be modified to
use the UPDAT and DELETE commands.
Bob
Private Function InsertXMLIntoDatabase(ByVal ds As DataSet) As Boolean
Dim connStr As String = "server=abc;uid=sa;pwd=pass;database=BobMS"
Dim sql As String = "SELECT * FROM tabTopFolder"
Dim insertStatus As Boolean = True
Dim dataConn As New
SqlConnection
(connStr)
Dim da As New
SqlDataAdapter
(sql, dataConn)
Dim cb As New
SqlCommandBuilder
(da)
Try
da.Update(ds, "tabTopFolder")
Catch exp As Exception
Response.Write("<br> " & exp.Message)
insertStatus = False
Finally
If dataConn.State <>
ConnectionState
.Closed Then
dataConn.Close()
End If
End Try
Return insertStatus
End Function 'InsertXMLIntoDatabase
| [ngfx-sqlclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp
= JOIN/QUIT
| [ngfx-sqlclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp
= JOIN/QUIT
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com
).
Version: 6.0.377 / Virus Database: 211 - Release Date: 07/15/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com
).
Version: 6.0.377 / Virus Database: 211 - Release Date: 07/15/2002
Reply to this message...
William \(Bill\) Vaughn (VIP)
It also is kinda dumb. The SQL it generates is pretty simplistic and
does not address a number of issues including Update Criteria (as set in
ADO classic), limiting the columns to update (it updates all columns),
using TimeStamps (they are ignored), returning the Identity... and more.
William (Bill) Vaughn
Author, trainer, mentor
Microsoft Regional Director -- Pacific Northwest
Beta V Corporation
Redmond, Washington USA
www.betav.com
(425) 556-9205 (v/f)
-----Original Message-----
From: Dan Wahlin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, July 26, 2002 12:46 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] RE:
SqlCommandBuilder
question
Also...it's quite convenient to use in some circumstances (and I'll use
it for more simple apps) but due to the round trip Bill mentioned it's
not as efficient as defining everything yourself. I saw a presentation
at Tech Ed by Michael Pizzo (Microsoft ADO.NET software architect) and
he basically said that if you want to maximize your performance don't
use it (which of course makes sense based upon Bill's statement).
Dan
Wahlin Consulting LLC
Microsoft MVP - ASP.NET
http://www.XMLforASP.NET
XML for ASP.NET Developers by Dan Wahlin in bookstores everywhere!
-----Original Message-----
From: William (Bill) Vaughn [mailto:
Click here to reveal e-mail address
]
Sent: Friday, July 26, 2002 12:36 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] RE:
SqlCommandBuilder
question
The CommandBuilder class takes the SELECT statement from the
DataAdapter
SelectCommand, parses it and makes a round trip to the server asking the
provider (and server) to describe the SQL. From that it congers the
UPDATE, INSERT and DELETE action queries and populates the
DataAdapter
commands appropriately.
hth
William (Bill) Vaughn
Author, trainer, mentor
Microsoft Regional Director -- Pacific Northwest
Beta V Corporation
Redmond, Washington USA
www.betav.com
(425) 556-9205 (v/f)
-----Original Message-----
From: Bob Herrmann [mailto:
Click here to reveal e-mail address
]
Sent: Friday, July 26, 2002 6:56 AM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient]
SqlCommandBuilder
question
-- Moved from [aspngdata] to [ngfx-sqlclient] by Sheik Yerbouti
<
Click here to reveal e-mail address
> --
Hi all,
I recently copied a snippet of code from a .Net web site which helped me
convert a XML file to SQL. The code does work as planned. I notice
this code uses a feature which I have not used before, specifically the
SqlCommandBuilder
. I have listed the code below. This code does the
INSERT into my SQL database. My question is the how the heck does it do
this? I do not see where the INSERT command is used in the
SqlCOmmandBuilder object. Can someone explain how this works so that I
can understand it? I'd also like to know how this could be modified to
use the UPDAT and DELETE commands.
Bob
Private Function InsertXMLIntoDatabase(ByVal ds As DataSet) As Boolean
Dim connStr As String = "server=abc;uid=sa;pwd=pass;database=BobMS"
Dim sql As String = "SELECT * FROM tabTopFolder"
Dim insertStatus As Boolean = True
Dim dataConn As New
SqlConnection
(connStr)
Dim da As New
SqlDataAdapter
(sql, dataConn)
Dim cb As New
SqlCommandBuilder
(da)
Try
da.Update(ds, "tabTopFolder")
Catch exp As Exception
Response.Write("<br> " & exp.Message)
insertStatus = False
Finally
If dataConn.State <>
ConnectionState
.Closed Then
dataConn.Close()
End If
End Try
Return insertStatus
End Function 'InsertXMLIntoDatabase
| [ngfx-sqlclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp
= JOIN/QUIT
| [ngfx-sqlclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp
= JOIN/QUIT
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com
).
Version: 6.0.377 / Virus Database: 211 - Release Date: 07/15/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com
).
Version: 6.0.377 / Virus Database: 211 - Release Date: 07/15/2002
| [ngfx-sqlclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp
= JOIN/QUIT
Reply to this message...
System.Data.Common.DataAdapter
System.Data.ConnectionState
System.Data.DataSet
System.Data.SqlClient.SqlCommandBuilder
System.Data.SqlClient.SqlConnection
System.Data.SqlClient.SqlDataAdapter
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com