944,118 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1884
  • VB.NET RSS
Apr 27th, 2007
0

problem with entering data in datagrid

Expand Post »
I am trying to enter data into a datagrid and I get this message
No value given for one or more required parameters. Can anyone see what is wrong. Here is the code

Imports System.data
Imports System.data.OleDb
Imports System.Configuration
Partial Class supplier
Inherits System.Web.UI.Page
Dim ConnString As String = ConfigurationManager.AppSettings("ConnString")
Dim dbPath As String = ConfigurationManager.AppSettings("PathDB")

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
getsuppliers()
dgsuppliers.DataSource = Session("Supplier")

End If
End Sub


Private Sub getsuppliers()

Dim mySQL As String = "select SupplierID, Supplier from Products "
Dim dbConn As New OleDbConnection(ConnString & Server.MapPath(dbPath))
Dim dbCommand As New OleDbCommand(mySQL, dbConn)
Dim dbAdapter As New OleDbDataAdapter(dbCommand)
Dim dsSuppliers As New DataSet


Try
dbConn.Open()
dbAdapter.Fill(dsSuppliers, "Suppliers")
Catch ex As Exception
lblResults.Text = "Error occurred when retrieving data from Table: " & ex.Message
Finally
dbConn.Close()
End Try
dgsuppliers.DataBind()
End Sub


Protected Sub dgsuppliers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgsuppliers.SelectedIndexChanged
Dim mysql As String = "Select SupplierID, Supplier, from Products where SupplierID=" & dgsuppliers.SelectedValue & ""
Dim dbConn As New OleDbConnection(ConnString & Server.MapPath(dbPath))
Dim dbCommand As New OleDbCommand(mysql, dbConn)
Dim dbAdapter As New OleDbDataAdapter(dbCommand)
Dim dsSuppliers As New DataSet
Dim supplierRow As DataRow
supplierRow = dsSuppliers.Tables("Suppliers").Rows(0)

lblResults.Text &= "<b>" & supplierRow("Company Name") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Contact Name") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Contact Title") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Address") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("City") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Region") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Postal Code") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Country") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Phone") & "</b><br>"
lblResults.Text &= "<b>" & supplierRow("Fax") & "</b><br>"





End Sub
End Class
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikki23 is offline Offline
4 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Helpp Plisssss
Next Thread in VB.NET Forum Timeline: SUM From Two Tables





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC