Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is it possible to bind data to an HTML table cell? If so, what's the syntax...?

 

For example - I want to show a specific person's record on a page. The source is an mdb file. There's two ways I can think of to do this, and one of them is using a datagrid, however that doesn't produce the desired results... If there's some way of showing a specific item in a cell, then I'd rather do that... Thanks in advance!

Posted
I don't think you can bind to an HTML table.

SOrry I didn't get it, what do you want to do?

Basically pull up a user or employee's record, showing their email address, mailing address, etc... Information that's stored in a database, and shown in a table.

 

Basically, like this.

  • Moderators
Posted

The link errors out, the msg is...

 

Line 39: objCN.Close()

Line 40: lblEmployeeID.Text = _

Line 41: objDS.Tables("EmployeeData").Rows(0)!EmployeeID

 

It looks like a Dataset is feeding a Label, the rest of it may be a DataGrid or DataList (as wyrd said).

Visit...Bassic Software
Posted

Okay... I got that... For some reason, it's still bugging out though. Can anyone help me out?

 

Sub Page_Load(Sender As Object, E As EventArgs)
		Dim objCN  as OleDbConnection	 'Database Connection object
		Dim objDA  as OleDbDataAdapter   'Database Adaptor object
                Dim objDS  as DataSet            'Dataset object
		Dim objCM  as OleDbCommand
		Dim strSQL as String
		Dim strCN  as String
	   
		If Not IsPostBack Then
			   strCN = "PROVIDER = Microsoft.Jet.OLEDB.4.0;" & "DATA SOURCE=" & Server.MapPath("emps.mdb;" ) 		   
  					    
			objCN = New OleDbConnection( strCN )	
			objCN.Open()
		
			strSQL = " SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = @EmployeeID"
			objDA = New OleDBDataAdapter( strSQL, objCN )
			objDA.SelectCommand.Parameters.Add("@EmployeeID")
			objDS = New DataSet
			objDA.Fill(objDS, "Employees")
			objCN.Close()
			lblEmployeeID.text = objDS.Tables("EmployeeData").Rows(0)!EmployeeID
			lblName.text = objDS.Tables("EmployeeData").Rows(0)!LastName
			lblDepartment.text = objDS.Tables("EmployeeData").Rows(0)!DepartmentID
			lblEmail.text = objDS.Tables("EmployeeData").Rows(0)!EmailAddress
			lblNumber.text = objDS.Tables("EmployeeData").Rows(0)!PhoneNumber
			lblNotes.text = objDS.Tables("EmployeeData").Rows(0)!Notes
		end if
	end sub

Posted

It's hard to tell without you posting the error messages, but a few things..

 

Change your page load to..

Sub Page_Load()

 

And also your connection string seems a little funky, perhaps change it to..

strCN = "PROVIDER = Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & Server.MapPath("emps.mdb")

 

And your parameter is wrong I believe. You're using the set up for SQL Server classes, but you're using OleDB. Change your sql select to;

strSQL = " SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = ?"

 

And also your parameter itself seems wrong. It should be ("@paramter", source) and all you have is parameter. Perhaps change it to something like;

objDA.SelectCommand.Parameters.Add("@EmployeeID", txtEmployeeID.Text)

 

As a last thing, you can bind data to ANY web control (as far as I know). I noticed that you're using labels, and you can bind data to your labels. I'd suggest searching for info in the MSDN library.

 

Anyway, hope that helps.. I have a limited knowledge of ASP.NET stuff, but hopefully I at least set you in the right direction. If you need more help post the code, the error message, and what line the error(s) are on.

Gamer extraordinaire. Programmer wannabe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...