Click here to Skip to main content
15,914,111 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Application or setup Pin
Dave Kreskowiak11-Feb-10 4:30
mveDave Kreskowiak11-Feb-10 4:30 
GeneralRe: Application or setup Pin
Gagan.2011-Feb-10 4:34
Gagan.2011-Feb-10 4:34 
GeneralRe: Application or setup Pin
The Man from U.N.C.L.E.11-Feb-10 13:15
The Man from U.N.C.L.E.11-Feb-10 13:15 
Questionvb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel10-Feb-10 22:18
gengel10-Feb-10 22:18 
AnswerRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
Dave Kreskowiak11-Feb-10 1:42
mveDave Kreskowiak11-Feb-10 1:42 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 2:12
gengel11-Feb-10 2:12 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
Dave Kreskowiak11-Feb-10 3:56
mveDave Kreskowiak11-Feb-10 3:56 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 4:12
gengel11-Feb-10 4:12 
Hi,

Hope this helps.


Datalayer class

Dim pDS As New DataSet

    Public Property DS() As DataSet
        Get
            Return pDS
        End Get
        Set(ByVal value As DataSet)
            pDS = value
        End Set
    End Property

Sub MakeConnect()
        SQLcon.ConnectionString = "Data Source=192.168.10.24\BDMS;" & _
                                        "Initial Catalog=FLATPAN;" & _
                                        "User ID=flatpan;" & _
                                        "Password=*******"
        Try
            SQLcon.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub
 
Function Load_Table(ByVal SQLString As String, ByVal TableName As String) As Boolean

        Dim SQLstr As String
        Dim tableISadded As Boolean = False
        Try
            'open connection
            If SQLcon.State = ConnectionState.Closed Then
                SQLcon.Open()
            End If
            SQLstr = SQLString
            Dim cmd As SqlCommand = New SqlCommand(SQLstr, SQLcon)
            Dim da As New SqlDataAdapter(SQLstr, SQLcon)
            da.Fill(pDS, TableName)
            da.FillSchema(pDS, SchemaType.Mapped)
            For Each dt As DataTable In pDS.Tables
                If dt.TableName = TableName Then
                    tableISadded = True
                Else
                    tableISadded = False
                End If
            Next
            Return tableISadded
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Return False
        Finally
            'close connection
            SQLcon.Close()
        End Try


On the orders form call the Load_Table function to add the table to the dataset. This works.
Private Sub Orders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       'Load the orders table and lu products table
       MAIN.data.Load_Table("SELECT * FROM Orders", "Orders") 'THIS IS THE DA FILL FOR ORDERS
       MAIN.data.Load_Table("SELECT * FROM LU_Products", "LU_Products")
       MAIN.data.Load_Table("SELECT * FROM Status_Orders", "Status_Orders")
       Calculate_Total_Rows(0, "LOAD") 'SOME FORM ACTIONS
       Fields_Load(rowCounter) 'NOT PART OF UPDATE ONLY TO VIEW DATA
       Fields_State("LOCK") 'LOCK FIELDS SO USER CANT CHANGE
   End Sub


Here add a new row to the ORDERS table. This works, but cannot see the changes to the database until I remove the datatable from the dataset and then fill it back again. I think this would be very noisy as we scan barcodes into a table that will become very large over time.

Function Add_Orders_Row() As Boolean
        Try
            Dim RowISAdded As Boolean = False
            If txtQuantity.Text <> "" And txtProductionNo.Text <> "" _
            And txtWeek.Text <> "" And txtPart.Text <> "" _
            And cboProductCode.Text <> "" And txtPart.Text <> "" _
            And txtWorksOrderNo.Text <> "" Then
                Dim dt As DataTable = MAIN.data.DS.Tables("Orders")
                Dim dr As DataRow = dt.NewRow
                dr.Item("OrderStatus") = cboOrderStatus.Text
                dr.Item("SamsungRef") = "NA"
                dr.Item("ProductCode") = cboProductCode.Text
                dr.Item("ProductSerialNo") = txtProductSerialNo.Text
                dr.Item("ProductionNo") = txtProductionNo.Text
                dr.Item("WeekNo") = txtWeek.Text
                dr.Item("PartNo") = CType(txtPart.Text, Integer)
                dr.Item("OrderDate") = dtpOrderDate.Text
                dr.Item("QuantityOrder") = CType(txtQuantity.Text, Integer)
                dr.Item("QuantityScanned") = 0
                dr.Item("WorksOrderNo") = txtWorksOrderNo.Text
                If txtFirstSerial.Text = "" Then
                    dr.Item("FirstSerialNo") = "<SCAN>"
                    dr.Item("LastSerialNo") = "<CALC>"
                Else
                    dr.Item("FirstSerialNo") = txtFirstSerial.Text
                    dr.Item("LastSerialNo") = txtLastSerial.Text
                End If
                dr.Item("timenow") = Date.Now
                dt.Rows.Add(dr)
                'Update new row to database
                Dim qry As String = "SELECT * FROM Orders"
                If MAIN.data.Conn.State = ConnectionState.Closed Then MAIN.data.Conn.Open()
                Dim da1 As New SqlClient.SqlDataAdapter
                da1.SelectCommand = New SqlClient.SqlCommand(qry, MAIN.data.Conn)
                Dim cb1 As SqlClient.SqlCommandBuilder = New System.Data.SqlClient.SqlCommandBuilder(da1)
                da1.Update(MAIN.data.DS, "Orders")
                
                'REMOVE THE DATABLE
                MAIN.data.DS.Tables.Remove("Orders")
                
                'Reatach datatable to dataset. Refresh primary keys
                MAIN.data.Load_Table("SELECT * FROM Orders", "Orders")
                
                'MAKE SURE UPDATE MADE
                Dim findrow As DataRow() = dt.Select("ProductionNo= '" & txtProductionNo.Text & "'")
                If findrow.Length = 1 Then
                    RowISAdded = True
                Else
                    RowISAdded = False
                End If
            Else
                                RowISAdded = False
            End If

            Return RowISAdded
        Catch ex As Exception
            MessageBox.Show("Add_Orders_Row, " & ex.Message)
            Return False
        End Try

    End Function

GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
Dave Kreskowiak11-Feb-10 5:02
mveDave Kreskowiak11-Feb-10 5:02 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner11-Feb-10 6:34
William Winner11-Feb-10 6:34 
AnswerRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner11-Feb-10 6:16
William Winner11-Feb-10 6:16 
AnswerRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner11-Feb-10 6:21
William Winner11-Feb-10 6:21 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 18:28
gengel11-Feb-10 18:28 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 18:30
gengel11-Feb-10 18:30 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 23:35
gengel11-Feb-10 23:35 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner12-Feb-10 6:09
William Winner12-Feb-10 6:09 
QuestionInternet Connection with VB 6 Pin
jayachandra.c10-Feb-10 19:45
jayachandra.c10-Feb-10 19:45 
AnswerRe: Internet Connection with VB 6 Pin
Eddy Vluggen10-Feb-10 21:27
professionalEddy Vluggen10-Feb-10 21:27 
GeneralRe: Internet Connection with VB 6 Pin
rhuiden11-Feb-10 8:56
rhuiden11-Feb-10 8:56 
QuestionHow to conver Exhadecimal to Text ? Pin
Golden Jing10-Feb-10 17:14
Golden Jing10-Feb-10 17:14 
AnswerRe: How to conver Exhadecimal to Text ? Pin
Eddy Vluggen10-Feb-10 21:46
professionalEddy Vluggen10-Feb-10 21:46 
GeneralRe: How to conver Exhadecimal to Text ? Pin
Golden Jing11-Feb-10 1:05
Golden Jing11-Feb-10 1:05 
GeneralRe: How to conver Exhadecimal to Text ? Pin
Golden Jing11-Feb-10 15:42
Golden Jing11-Feb-10 15:42 
GeneralRe: How to conver Exhadecimal to Text ? Pin
Eddy Vluggen12-Feb-10 0:02
professionalEddy Vluggen12-Feb-10 0:02 
GeneralRe: How to conver Exhadecimal to Text ? Pin
Golden Jing14-Feb-10 22:15
Golden Jing14-Feb-10 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.