Click here to Skip to main content
15,923,789 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
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 
Hi,

I am a little confused now. the code that I am using is based on several references and websites. I thought that was the idea of ADO.net. Work with data offline. What is the corrct way of doing this.

I have tried to simplify my code below.

Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Example
    Dim SQLcon As New SqlConnection
    Dim pDS As New DataSet

    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

    Sub Load_Table()
        Dim SQLstr As String = "SELECT * FROM Orders"
        Try
            'open connection
            If SQLcon.State = ConnectionState.Closed Then
                SQLcon.Open()
            End If
            Dim cmd As SqlCommand = New SqlCommand(SQLstr, SQLcon)
            Dim da As New SqlDataAdapter(SQLstr, SQLcon)
            da.Fill(pDS, "ORDERS")
            
            'Added this to see if it helped
            da.FillSchema(pDS, SchemaType.Mapped)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            'close connection
            SQLcon.Close()
        End Try
    End Sub

    Sub Add_New_Record()
        Try
            Dim dt As DataTable = pDS.Tables("Orders")
            Dim dr As DataRow = dt.NewRow
            dr.Item("OrderStatus") = "A"
            dr.Item("SamsungRef") = "B"
            dr.Item("ProductCode") = "C"
            dr.Item("ProductSerialNo") = "D"
            dr.Item("ProductionNo") = "E"
            dt.Rows.Add(dr)

            'Update new row to database
            Dim qry As String = "SELECT * FROM Orders"
            If SQLcon.State = ConnectionState.Closed Then SQLcon.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(pDS, "Orders")

            'Had to add this to register change in dataset
            pDS.Tables.Remove("Orders")
            'Reatach datatable to dataset. Refresh primary keys
            MAIN.data.Load_Table("SELECT * FROM Orders", "Orders")

        Catch ex As Exception
            MessageBox.Show("Add_New_Record, " & ex.Message)
        End Try
    End Sub
End Class

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 
QuestionFile Transfer from PPC Pin
Dominick Marciano10-Feb-10 9:28
professionalDominick Marciano10-Feb-10 9:28 
Questionclient in same lan help me Pin
Cosby10-Feb-10 5:26
Cosby10-Feb-10 5:26 
AnswerRe: client in same lan help me Pin
Eddy Vluggen10-Feb-10 21:49
professionalEddy Vluggen10-Feb-10 21:49 
GeneralRe: client in same lan help me Pin
Cosby10-Feb-10 21:54
Cosby10-Feb-10 21:54 
QuestionWake On Lan HELP Pin
Cosby10-Feb-10 5:25
Cosby10-Feb-10 5:25 

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.