Click here to Skip to main content
16,017,015 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionPrevent other app's I/O Pin
The real $M@1-Jul-09 20:11
The real $M@1-Jul-09 20:11 
AnswerRe: Prevent other app's I/O Pin
Eddy Vluggen2-Jul-09 0:24
professionalEddy Vluggen2-Jul-09 0:24 
QuestionHow to approach for reports in word. Pin
nazimghori1-Jul-09 16:47
nazimghori1-Jul-09 16:47 
AnswerRe: How to approach for reports in word. Pin
Tom Deketelaere1-Jul-09 22:30
professionalTom Deketelaere1-Jul-09 22:30 
Questionhow to use euresys library in vb 2008 Pin
zhiyuan161-Jul-09 15:30
zhiyuan161-Jul-09 15:30 
QuestionRe: how to use euresys library in vb 2008 Pin
EliottA1-Jul-09 16:31
EliottA1-Jul-09 16:31 
AnswerRe: how to use euresys library in vb 2008 Pin
Dave Kreskowiak1-Jul-09 19:16
mveDave Kreskowiak1-Jul-09 19:16 
QuestionVB.NET 2005 - Refresh Databinding and Reset of Checkboxes Pin
Fry1001-Jul-09 4:35
Fry1001-Jul-09 4:35 
Hello,

I'm hoping that someone can help with two problems I currently have with databinding.

1. I have a couple of checkboxes bound to a form and if I clear my dataset before I change my application to point to another customer, any checkboxes with a checkedstate of checked are reset to unchecked and this is saved in SQL.

2. If I do not clear my dataset before I point to another customer in my application, the correct checkbox state is saved in SQL, however, my databound controls retain customer A's data rather than refreshing with customer B's.

I am connecting to SQL using:


Public Sub SetupDataConnections(ByVal strSQLSelectString As String, ByVal myDataSet As DataSet, ByVal myDataSetName As String, _
    Optional ByVal mySQLParameters As SqlParameter() = Nothing)

        Try

            mySQLConnection = New SqlConnection(_connectionString)
            mySQLConnection.Open()

            ' -- Check connection state
            If mySQLConnection.State = ConnectionState.Open Then

                myDataAdapter = New SqlDataAdapter(New SqlCommand(strSQLSelectString, mySQLConnection))

                ' -- If we have some parameters, add them to our command
                If Not mySQLParameters Is Nothing Then

                    myDataAdapter.SelectCommand.Parameters.AddRange(mySQLParameters)

                End If

                If Not myDataAdapter Is Nothing Then

                    Using myBindingSource

                        myDataAdapter.Fill(myDataSet, myDataSetName)
                        myBindingSource.DataSource = myDataSet
                        myBindingSource.ResetBindings(False)

                    End Using

                Else

                    CatchError("You must first create a SQL connection before calling this function")

                End If

            End If

        Catch ex As Exception

            CatchError(ex)

        End Try

    End Sub




Following this Sub, I proceed through:

Public Function SetupBindings(ByVal myDataSet As DataSet, ByVal myDataSetName As String, ByVal myForm As Control) As Dictionary(Of String, Date)

       myBindingSource.DataSource = myDataSet

        For Each myControl As Control In myForm.Controls

            Try

                myControl.DataBindings.Clear()

                If (TypeOf myControl Is TextBox OrElse TypeOf myControl Is ComboBox) AndAlso Not (myControl.Tag Is "" Or myControl.Tag Is Nothing) Then

                    myControl.DataBindings.Add("Text", myDataSet.Tables(myDataSetName), myDataSet.Tables(myDataSetName).Columns(GetColumnNameFromControlTag _
                    (myControl.Tag.ToString)).ToString, True, DataSourceUpdateMode.OnPropertyChanged)

                    '-- Bind data to associated textbox control
                ElseIf (TypeOf myControl Is DateTimePicker OrElse TypeOf myControl Is DateTimeControl) AndAlso Not (myControl.Tag Is "" Or myControl.Tag Is Nothing) Then

    '--  ... CONTINUE FOR EACH TYPE OF CONTROL BOUND TO THE FORM ...

                ElseIf myControl.HasChildren Then ' -- Recurse back in to function if there are children

                    SetupBindings(myDataSet, myDataSetName, myControl)

                End If

            Catch ex As Exception

                CatchError(ex)

            End Try

        Next

    End Function




And those two subs set up my data binding. Each control's tag contains the DATABASE.COLUMN mapping.

I would greatly appreciate any assistance.

Cheers,
James
QuestionWhere to store additional files Pin
Mithun.Shitole1-Jul-09 2:53
Mithun.Shitole1-Jul-09 2:53 
AnswerRe: Where to store additional files Pin
Johan Hakkesteegt1-Jul-09 3:04
Johan Hakkesteegt1-Jul-09 3:04 
GeneralRe: Where to store additional files Pin
Mithun.Shitole1-Jul-09 3:10
Mithun.Shitole1-Jul-09 3:10 
AnswerRe: Where to store additional files Pin
Tom Deketelaere1-Jul-09 3:44
professionalTom Deketelaere1-Jul-09 3:44 
AnswerRe: Where to store additional files Pin
TheMrProgrammer1-Jul-09 5:43
TheMrProgrammer1-Jul-09 5:43 
AnswerRe: Where to store additional files Pin
DoctorMick1-Jul-09 5:59
DoctorMick1-Jul-09 5:59 
QuestionRun Crystal Reports without installation Pin
Hypermommy1-Jul-09 2:31
Hypermommy1-Jul-09 2:31 
AnswerRe: Run Crystal Reports without installation Pin
Kschuler1-Jul-09 5:51
Kschuler1-Jul-09 5:51 
GeneralRe: Run Crystal Reports without installation Pin
Hypermommy1-Jul-09 6:54
Hypermommy1-Jul-09 6:54 
AnswerRe: Run Crystal Reports without installation Pin
tosch1-Jul-09 22:02
tosch1-Jul-09 22:02 
QuestionAdd Button to Tab Title Pin
Yose Antony1-Jul-09 1:01
Yose Antony1-Jul-09 1:01 
AnswerRe: Add Button to Tab Title Pin
dan!sh 1-Jul-09 2:07
professional dan!sh 1-Jul-09 2:07 
GeneralRe: Add Button to Tab Title Pin
Yose Antony1-Jul-09 18:21
Yose Antony1-Jul-09 18:21 
GeneralRe: Add Button to Tab Title Pin
Dave Kreskowiak1-Jul-09 19:13
mveDave Kreskowiak1-Jul-09 19:13 
GeneralRe: Add Button to Tab Title Pin
dan!sh 1-Jul-09 19:27
professional dan!sh 1-Jul-09 19:27 
GeneralRe: Add Button to Tab Title Pin
Andy_L_J1-Jul-09 22:00
Andy_L_J1-Jul-09 22:00 
GeneralRe: Add Button to Tab Title Pin
Yose Antony11-Jul-09 0:30
Yose Antony11-Jul-09 0:30 

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.