Hi there


Ok so I managed to get rid of the error message but now no data is been displayed on the datagridviews...

Can anyone suggest what I need to add to my code to get the datagrids displaying the information that I want?

My updated code.
VB Code:
  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3.  
  4. Public Class frmCustomers
  5.     Inherits System.Windows.Forms.Form
  6.  
  7.    
  8.  
  9.  
  10.  
  11.  
  12.     Dim objConnection As SqlConnection = New _
  13.         SqlConnection("server= nx6130;database=actionglass;user id=sa;Trusted_Connection=True;")
  14.     Dim objDataAdapter As SqlDataAdapter = New SqlDataAdapter( _
  15.         "SELECT tblCustomers.CustomerName,ContactName,PhoneNumber,FaxNumber,MobNumber,EmailAddress,Address1,Address2,Address3,Address4,DAddress1,DAddress2,DAddress3,DAddress4,Comments,CustomerID " & _
  16.         "FROM tblCustomers " & _
  17.         "ORDER BY CustomerName", objConnection)
  18.  
  19.     Dim objDataSet As DataSet
  20.     Dim objDataView As DataView
  21.  
  22.  
  23.  
  24. Private Sub frmCustomers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  25.  
  26.         Me.WindowState = FormWindowState.Maximized
  27.  
  28.         FillDataSetAndView()
  29.         BindFields()
  30.         Dim conn As New SqlClient.SqlConnection("Server = " & "nx6130" & _
  31.                 "; Database = ActionGlass; " & _
  32.                 "Integrated Security  = sspi;")
  33.  
  34.         Dim ds As New DataSet
  35.  
  36.         Dim daQuotes As New SqlClient.SqlDataAdapter("SELECT * FROM tblQuotes WHERE tblquotes.CustomerID = '" & txtCustomerID.Text & "'", conn)
  37.         Dim daOrders As New SqlClient.SqlDataAdapter("SELECT * FROM tblOrders WHERE tblOrders.CustomerID = '" & txtCustomerID.Text & "'", conn)
  38.         Dim daPayments As New SqlClient.SqlDataAdapter("SELECT * FROM tblPayments WHERE tblPayments.CustomerID = '" & txtCustomerID.Text & "'", conn)
  39.         'Dim daOrders As New SqlClient.SqlDataAdapter("SELECT * from tblOrders", conn)
  40.  
  41.         daOrders.Fill(ds, "tblOrders")
  42.         daQuotes.Fill(ds, "tblQuotes")
  43.         daPayments.Fill(ds, "tblPayments")
  44.  
  45.         grdInvoices.ReadOnly = True
  46.         grdQuotes.ReadOnly = True
  47.         grdPayments.ReadOnly = True
  48.         grdInvoices.AllowUserToAddRows = False
  49.         grdInvoices.DataSource = ds
  50.         grdQuotes.DataSource = ds
  51.         grdPayments.DataSource = ds
  52.         grdInvoices.DataMember = "tblOrders"
  53.         grdQuotes.DataMember = "tblQuotes"
  54.         grdPayments.DataMember = "tblPayments"
  55.  
  56.  
  57.  
  58.  
  59.         With grdQuotes
  60.  
  61.             '  .Columns("QuoteID").HeaderText = "Quote ID"
  62.             ' .Columns("DateOfQuote").HeaderText = "Date Of Quote"
  63.  
  64.         End With
  65.  
  66.     End Sub

Thanks for the advise on entering data directly into a query. I was not aware of that. (Yes im fresh from over from access)

Thanks