Newbie ASP.NET question: inserting data in table

  • Thread starter Thread starter planetthoughtful
  • Start date Start date
P

planetthoughtful

Hi All,

I'm in that painful beginning stage of trying to wrap my head around C#
in ASP.NET - so I will apologise in advance for asking silly questions
and hope the assembled will be forgiving.

Ooookay - I have a fairly simple data entry form and when the user
clicks the submit button I want to insert the values from the fields on
the form into an existing table in SQL Server 2000.

At this point I have two textboxes on the form, with IDs of txtSubject
and txtSummary, along with a submit button with an onserverclick
attribute of fnInsertRecord.

My table is called tblArticles and it contains a seeded autonumber
field and two other fields named (no surprises) subject and summary.

Can anyone help me figure out what in the name of sanity should go in
the following to insert the record in tblArticles and update the
changes back to the database?

private void fnWriteRecord(object sender, EventArgs e){

// mysterious stuff required here

}

Many thanks for any help!

Much warmth,

planetthoughtful
 
At this point I have two textboxes on the form, with IDs of txtSubject
and txtSummary, along with a submit button with an onserverclick
attribute of fnInsertRecord.
[snip]

private void fnWriteRecord(object sender, EventArgs e){

// mysterious stuff required here

}

Sigh. The observant will pickup the fact that I've provided two
different names in the onserverclick attribute and the name of the
function being called (ie "fnInsertRecord" in one and "fnWriteRecord"
in the other). This is a clerical error on my part when I was writing
my original post, and isn't the cause of my problem.

I'm truly trying to work out the actual syntax for inserting a record
into a table using values provided in a form.

Sorry for the confusion.

Much warmth,

planetthoughtful
 
Can anyone help me figure out what in the name of sanity should go in
the following to insert the record in tblArticles and update the
changes back to the database?

private void fnWriteRecord(object sender, EventArgs e){

// mysterious stuff required here

}

Aha! With some more reading and experimentation, I've discovered the
use of SqlCommand to perform an insert, so all seems to be working!

Thanks to anyone who gave this some thought.

Much warmth,

planetthoughtful
 

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

Back
Top