| | |
problem with entering data in datagrid
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2007
Posts: 4
Reputation:
Solved Threads: 0
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
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
- Insert & Edit Data in DataGrid (VB.NET)
- Modify data in Datagrid (VB.NET)
- Datagrid to draw a table (C#)
- asp problem ADODB.Recordset error '800a0bb9' (ASP)
- problem again (C)
- Problem with CRT monitor Data Cable (Monitors, Displays and Video Cards)
- How to sort the rows in the datagrid and update it successfully? (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Helpp Plisssss
- Next Thread: SUM From Two Tables
Views: 1632 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center class click client code combo convert cuesent data database datagrid datagridview date datetimepicker design designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images lib listview map mobile module msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read refresh regex richtextbox right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver studio temperature textbox timer timespan transparency txttoxmlconverter usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year





