Jump to content

MYSQL and ASP.net


Recommended Posts

Hi guys,

Need your help here, im a begginer in .net programming.

I have a table that contains only one row of data.

this is the table script:

CREATE TABLE `tblsiteconfig` (
`uscfid` int(1) AUTO_INCREMENT NOT NULL COMMENT 'Unique site config key value',
`sitetitle` varchar(50) NOT NULL COMMENT 'Website title',
`sitedescription` varchar(100) NOT NULL COMMENT 'Website description for meta tag generation',
`sitekeywords` varchar(200) NOT NULL COMMENT 'Website keywords for meta tag generations for search engine indexing',
`sitecopyright` varchar(200) NOT NULL COMMENT 'Website copyright notice to be displayed at the footer of every page',
`siteadminemail` varchar(50) NOT NULL COMMENT 'Website webmaster email',
`sitetelephone` varchar(20) NOT NULL COMMENT 'Website telephone number',
`sitemaintenance` tinyint(1) COMMENT 'Website maintenance status',
`sitenews` tinyint(1) COMMENT 'Enable/Disable site news',
`sitepoll` tinyint(1) COMMENT 'Enable/Disable site poll',
/* Keys */
PRIMARY KEY (`uscfid`)
) ENGINE = InnoDB
COMMENT = 'Table containg basic site configuration parameter';

now, i can get the data to be displayed if i use these codes:

Imports System.Data
Imports System.Data.Odbc

Protected Sub btnConnectMYSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnConnectMYSQL.Click
Dim myConnection As OdbcConnection = New OdbcConnection(ConfigurationManager.ConnectionStrings("MYSQLDBCON").ConnectionString)
Dim sSQL As String = "select * from tblsiteconfig where uscfid=1"
Dim oDataAdapter As OdbcDataAdapter = New OdbcDataAdapter(sSQL, myConnection)
Dim oDataSet As DataSet = New DataSet()
oDataAdapter.Fill(oDataSet)
grdDisplayData.DataSource = oDataSet
grdDisplayData.DataBind()
End Sub

This populates the whole data into a grid. but, how can i change the code above so that i can assign individual value to a text box?

eg:

txtsitetitle.text = [sitetitle from database]

Thanks in advance.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...