Click here to Skip to main content
15,889,335 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: locate the FILESTREAM data Pin
Richard MacCutchan3-Dec-13 3:13
mveRichard MacCutchan3-Dec-13 3:13 
AnswerRe: locate the FILESTREAM data Pin
RedDk3-Dec-13 10:35
RedDk3-Dec-13 10:35 
GeneralRe: locate the FILESTREAM data Pin
Pete O'Hanlon3-Dec-13 10:49
mvePete O'Hanlon3-Dec-13 10:49 
GeneralRe: locate the FILESTREAM data Pin
RedDk3-Dec-13 11:07
RedDk3-Dec-13 11:07 
GeneralRe: locate the FILESTREAM data Pin
Dave Kreskowiak3-Dec-13 15:01
mveDave Kreskowiak3-Dec-13 15:01 
GeneralRe: locate the FILESTREAM data Pin
Pete O'Hanlon3-Dec-13 19:18
mvePete O'Hanlon3-Dec-13 19:18 
GeneralRe: locate the FILESTREAM data Pin
Member 103249743-Dec-13 23:16
Member 103249743-Dec-13 23:16 
QuestionAccess to SQL Pin
Member 103884942-Dec-13 1:04
Member 103884942-Dec-13 1:04 
Hello. I need a hand in my code. i wrote the following code. and i am trying to work with sql.
what should i change?
I really need some help with this :/
VB
Public Class BindingContext
    Dim _cn As New OleDb.OleDbConnection
    Dim _DataAdapter As New OleDb.OleDbDataAdapter()
    Dim _CommandBuilder As OleDb.OleDbCommandBuilder
    Dim _DataSet As New System.Data.DataSet()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim _provider As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
        Dim _fullPath As String = "C:\Working Storage\Developments\LAB\Database Connection\Database Connection\Database\"
        Dim _dataSource As String = "Data Source=" & _fullPath & "ADOnet.MDB"
        _cn = New OleDb.OleDbConnection(_provider & _dataSource)
        _DataAdapter.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM tblCustomer", _cn)
        _DataSet = New DataSet()
        Try
            _DataAdapter.Fill(_DataSet)
        Catch eror As Exception
            MsgBox(eror.Message)
        End Try
        cbDept.DataSource = _DataSet.Tables(0)
        cbDept.DisplayMember = "Name"
        cbDept.ValueMember = "ID"
        Me.txtName.Text = "Sjflkjasdlk=fj"
        txtName.DataBindings.Add("text", _DataSet.Tables("tblCustomer"), "Name")
        txtEmail.DataBindings.Add("text", _DataSet.Tables(0), "Email")
        txtAddress.DataBindings.Add("text", _DataSet.Tables(0), "Address")
        cbDept.DataBindings.Add("SelectedValue", _DataSet.Tables(0), "DeptID")
    End Sub
    Private Sub cmdRequery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRequery.Click
        DBRequery()
        Me.BindingContext(_DataSet.Tables(0)).CancelCurrentEdit()
        Me.BindingContext(_DataSet.Tables(0)).Position = 0
        RefreshData(True)
    End Sub
    Private Sub DBRequery()
        cmdSave.Enabled = False
        _DataSet.Clear()
        Try
            _DataAdapter.Fill(_DataSet)
        Catch Eror As Exception
            cmdAdd.Enabled = False
            cmdUpdate.Enabled = False
            cmdDelete.Enabled = False
            MsgBox(Eror.Message, MsgBoxStyle.Exclamation, "Error Opening Database")
            Close()
            Exit Sub
        End Try
        txtCount.Text = Format(_DataSet.Tables(0).Rows.Count, "#,##0")
        If _DataSet.Tables(0).Rows.Count > 0 Then
            txtCurrent.Text = "1"
            EnableNavigation()
        End If
        cmdAdd.Enabled = True
    End Sub
 
 
    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        Try
            _DataAdapter.Update(_DataSet)
        Catch eror As Exception
            MsgBox("This was an error updating database." & ControlChars.CrLf & _
                eror.Message)
        End Try
    End Sub
    Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
        If IsNumeric(txtGoto.Text) Then
            If CInt(txtGoto.Text) = CDec(txtGoto.Text) Then
                If 1 <= CInt(txtGoto.Text) And CInt(txtGoto.Text) <= CInt(txtCount.Text) Then
                    BindingContext(_DataSet.Tables(0)).Position = CInt(txtGoto.Text) - 1
                    RefreshData(True)
                Else
                    GotoError()
                    Exit Sub
                End If
            Else
                GotoError()
                Exit Sub
            End If
        Else
            GotoError()
            Exit Sub
        End If
    End Sub
 Private Sub GotoError()
        MsgBox("This must be an integer between 1 and " & txtCount.Text & " inclusive", MsgBoxStyle.Exclamation)
    End Sub
 Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
        Dim pDataRow As DataRow
        pDataRow = _DataSet.Tables(0).NewRow()
        pDataRow!name = txtName.Text
        pDataRow!email = txtEmail.Text
        pDataRow!Address = txtAddress.Text
        _DataSet.Tables(0).Rows.Add(pDataRow)
        txtCount.Text = CStr(CInt(txtCount.Text) + 1)
        cmdSave.Enabled = True  ' let user update the underlying database
        txtCurrent.Text = txtCount.Text ' make the current row, the last (recently added) row
        EnableNavigation()
    End Sub
    Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
        Dim pDataRow As DataRow
        pDataRow = _DataSet.Tables(0).Rows(CInt(txtCurrent.Text) - 1)
        BindingContext(_DataSet.Tables(0)).EndCurrentEdit()
        pDataRow!name = txtName.Text
        pDataRow!email = txtEmail.Text
        pDataRow!address = txtAddress.Text
        cmdSave.Enabled = True  ' let user update the underlying database
    End Sub
 Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        BindingContext(_DataSet.Tables(0)).RemoveAt(BindingContext(_DataSet.Tables(0)).Position)
        txtCount.Text = CStr(CInt(txtCount.Text) - 1)
        RefreshData(True)
        cmdSave.Enabled = True
    End Sub
End Class


Thank you sooo much for your time
AnswerRe: Access to SQL Pin
Simon_Whale2-Dec-13 1:09
Simon_Whale2-Dec-13 1:09 
GeneralRe: Access to SQL Pin
Member 103884942-Dec-13 1:12
Member 103884942-Dec-13 1:12 
GeneralRe: Access to SQL Pin
Member 103884942-Dec-13 1:21
Member 103884942-Dec-13 1:21 
GeneralRe: Access to SQL Pin
Simon_Whale2-Dec-13 1:27
Simon_Whale2-Dec-13 1:27 
GeneralRe: Access to SQL Pin
Member 103884942-Dec-13 2:15
Member 103884942-Dec-13 2:15 
GeneralRe: Access to SQL Pin
Simon_Whale2-Dec-13 3:04
Simon_Whale2-Dec-13 3:04 
GeneralRe: Access to SQL Pin
Member 103884942-Dec-13 3:06
Member 103884942-Dec-13 3:06 
GeneralRe: Access to SQL. Pin
Member 103884942-Dec-13 2:19
Member 103884942-Dec-13 2:19 
GeneralRe: Access to SQL. Pin
Dave Kreskowiak2-Dec-13 2:47
mveDave Kreskowiak2-Dec-13 2:47 
QuestionRtf,vb.net Pin
srinivasankrishnaa22-Nov-13 4:49
srinivasankrishnaa22-Nov-13 4:49 
AnswerRe: Rtf,vb.net Pin
Dave Kreskowiak22-Nov-13 6:20
mveDave Kreskowiak22-Nov-13 6:20 
AnswerRe: Rtf,vb.net Pin
Eddy Vluggen28-Nov-13 9:41
professionalEddy Vluggen28-Nov-13 9:41 
Questionwindow form to wpf Pin
Member 1026351918-Nov-13 22:41
Member 1026351918-Nov-13 22:41 
AnswerRe: window form to wpf Pin
Abhinav S18-Nov-13 22:47
Abhinav S18-Nov-13 22:47 
Question.net4.0 Pin
Member 1026351918-Nov-13 18:27
Member 1026351918-Nov-13 18:27 
AnswerRe: .net4.0 Pin
Abhinav S18-Nov-13 22:46
Abhinav S18-Nov-13 22:46 
AnswerRe: .net4.0 Pin
joginder-banger15-Dec-13 8:13
professionaljoginder-banger15-Dec-13 8:13 

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.