Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Searching problem in Vb.net

$
0
0
I am new to VB.net. I have project in which i have to use any database e.g. Access, SQL. I have to Access to connect with VB.net. I have to register user then search the user and delete it. I am able to Add the user to the data base using the following code, but i tried to search but i was failed because i am totally beginner. I will really appreciate if you guys help me. Thanks.

Imports System.Data
Imports System.Data.OleDb
Public Class DocAdd

 Dim con As New OleDb.OleDbConnection
    Dim cn As OleDb.OleDbConnection
    Dim str As String
    Dim cmd As OleDbCommand
    Dim da As New OleDbDataAdapter
    Dim sql As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        

    End Sub

    Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        Dim connectionStr As String
        connectionStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\My PC\Desktop\MOMS\MOMS\WindowsApplication2\MOMS.accdb"
        Dim cn As OleDbConnection = New OleDbConnection(connectionStr)

        cn.Open()
        sql = "INSERT INTO [Doctor] ([Doctor ID],[Surname],[Title],[Address],[City Town],[State],[Zip],[RegNo],[Phone No],[Mobile No],[Unit Code],[Category])values('" & txtdoctorid.Text & "', '" & txtsurname.Text & "', '" & txttitle.Text & "', '" & txtaddress.Text & "', '" & txtcitytown.Text & "', '" & txtstate.Text & "', '" & txtzip.Text & "', '" & txtregno.Text & "', '" & txtphoneno.Text & "', '" & txtmobileno.Text & "', '" & txtunitcode.Text & "', '" & txtcategory.Text & "')"
        'Try
        cmd = New OleDbCommand(sql, cn)
        cmd.ExecuteNonQuery()
        'Catch ex As Exception
        'Finally
        cn.Close()
        'End Try

        If txtdoctorid.Text = "" Or txtsurname.Text = "" Or txttitle.Text = "" Or txtaddress.Text = "" Or txtcitytown.Text = "" Or txtstate.Text = "" Or txtzip.Text = "" Or txtregno.Text = "" Or txtphoneno.Text = "" Or txtmobileno.Text = "" Or txtunitcode.Text = "" Or txtcategory.Text = "" = True Then

            MessageBox.Show("The registration form is not complete.", "Registration Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)

        Else
            MessageBox.Show("Register Successful !", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information)


        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        DocChange.Show()
        Me.Hide()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        DocDelete.Show()
        Me.Hide()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        DocEnquiry.Show()
        Me.Hide()

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Main_Menu.Show()
        Me.Hide()

    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Application.Exit()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        DocListing.Show()
        Me.Hide()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        
    End Sub
    Class Doc_Add

    End Class

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub
End Class


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>