Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

ASP.Net Form to Database

  Asked By: Jimmy    Date: Jan 06    Category: Asp.net    Views: 1402
  

I have a form with many controls, radio buttons, dropdown lists,
textx boxes, etc. How do I get them to talk to my database?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Leonard Pierce     Answered On: Jan 06

Have a look at the quickstart tutorial at:
http://www.asp.net/Tutorials/quickstart.aspx. You'll have to 'DataBind' your
database data to your controls  that behave as objects which have DataSource
properties.

 
Answer #2    Answered By: Elisabeth Bell     Answered On: Jan 06

#1
http://www.learnasp.com/freebook/learn/index.aspx?caller=utilitybelt§ion=Databases
the first 6 lessons show you exactly that.

#2 Common Sin:
Using Datasets to fill because the the Micrososft Quickstarts Docs do (mostly because they were written in Beta1 before ExecuteReader existed) , i.e.


Dim DS As DataSet
Dim MyConnection As OLEDBConnection
Dim MyCommand As OLEDBDataAdapter

MyConnection = New OLEDBConnection("....")
MyCommand = New OLEDBDataAdapter("select * from publishers where
state='NY'", MyConnection)

DS = new DataSet()
MyCommand.Fill(ds, "NYStateOfMind")

MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
MyDataGrid.DataBind()
MYConnection.Close()

when a
=> Executereader does the job much much much faster <=
without all the overhead of dataset object and with less code:

Dim MyConnection As new OLEDBConnection("....")
Dim MyCommand As OLEDBCommand("select * from publishers where state='NY'")
DIM myreader as new
OLEBDBReader()=MyCommand.ExecuteReader(system.data.commandbehavior.closeconnection)
MyDataGrid.DataSource=myreader
MyDataGrid.DataBind()
myReader.Close()

 
Didn't find what you were looking for? Find more on ASP.Net Form to Database Or get search suggestion and latest updates.




Tagged: