Easy Visual C# Insert Record Tip?

G

gregarican

I have a simple VC# form that validates its text boxes' contents and I
want to insert these text box contents into an SQL Server 2005 Express
DB. I have added the DB as a data source but right off the bat most of
what I see in terms of visual controls are data grids for displaying
row data and whatnot. What's an easy way to insert my record? In other
words if I start to manually code the insert SQL method how do I refer
to the data source I have added on the visual end?
 
G

gregarican

I have a simple VC# form that validates its text boxes' contents and I
want to insert these text box contents into an SQL Server 2005 Express
DB. I have added the DB as a data source but right off the bat most of
what I see in terms of visual controls are data grids for displaying
row data and whatnot. What's an easy way to insert my record? In other
words if I start to manually code the insert SQL method how do I refer
to the data source I have added on the visual end?

Please disregard. I failed to RTFM and realize that I was looking at
the DataSet and DataTable, but needed to invoke the Insert() method
provided by the TableAdapter.
 
K

Kevin Spencer

Actually, all you need is a SqlConnection and a SqlCommand, unless you want
to bind to a DataSet or DataTable.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.
 
G

gregarican

Actually, all you need is a SqlConnection and a SqlCommand, unless you want
to bind to a DataSet or DataTable.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.







- Show quoted text -

True. I've programmatically used the SqlConnection and SqlCommand
methods when writing ASP code. I just wanted to grasp the IDE way of
achieving something similar using Visual Studio 2005. Now I think I've
gotten my head around the DataSet, DataTable, TableAdapter, etc.
concepts newly introduced with the newer .NET releases. I come from a
background of using other languages like Ruby, Python, and Smalltak.
The middleman idea of the SQL adapter reminds me of some Smalltalk
variations that use presenters and containers to separate the GUI and
underlying logic. MVP/MVC and whatnot...
 
K

Kevin Spencer

Well, you're adding a lot of overhead if all you want to do is an insert. If
you want to be able to edit and update, that's another story.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.
 
G

gregarican

Well, you're adding a lot of overhead if all you want to do is an insert. If
you want to be able to edit and update, that's another story.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.

Good point. This was more just an exercise of getting to know the new
tools at my disposal. Yeah I could've just as easily thrown in a
couple lines of code to accomplish the same things without all of the
extra file baggage :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top