Quantcast
Channel: VBForums
Viewing all 42106 articles
Browse latest View live

VS 2010 Displaying a Image previous scanned or retrieved in Picturebox

$
0
0
I just want some help for my project which is RFID attendance system. The RFID tag should be scan to retrieve the information and Image from the database mysql. The first student will scan his RFID tag to display his picture in picturebox1 and when another student scan the picturebox1 will be updated to a new student picture and data and the previous one is on the picturebox2 displayed The issue here is how can I display the previous Image of the student. Just only the Image ,the data is not included.

I have a 2 picturebox

Picturebox1 is for new student scanned Picturebox2 is for the previous one or the student who scan before the new.

Thank you guys ..Any suggestions and comment will totally appreciated

Here is my code

Code:

Private Sub studtag_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles studtag.TextChanged
    If studtag.TextLength = 8 Then


        con = New MySqlConnection
        con.ConnectionString = "server=localhost;userid=root;password=1234;database=dat"
        Dim query As String

        query = "select * from dat.students"
        cmd = New MySqlCommand(query, con)



        Dim table As New DataTable

        Try
            con.Open()
            'Gets or sets an SQL statement or stored procedure used to select records in the database.
            With cmd
                .Connection = con
                .CommandText = "SELECT * from students where `studtags`='" & studtag.Text & "';"
            End With
            da.SelectCommand = cmd
            da.Fill(table)
            'it gets the data from specific column and fill it into textbox
            studtag.Text = table.Rows(0).Item(0)
            idno.Text = table.Rows(0).Item(1)
            lastxt.Text = table.Rows(0).Item(2)
            firstxt.Text = table.Rows(0).Item(3)
            middletxt.Text = table.Rows(0).Item(4)
            dob.Text = table.Rows(0).Item(6)

            crsetxt.Text = table.Rows(0).Item(10)

            tagtxt.Text = studtag.Text
            timein.Text = times.Text

            dr = cmd.ExecuteReader()
            dr.Read()

            If dob.Text = datenow.Text Then
                greet.Text = "Happy Birthday To You"

            End If



            Dim img() As Byte = CType(dr("studpic"), Byte())


            Using ms As New IO.MemoryStream(img)
                PictureBox1.Image = Image.FromStream(ms)

            End Using
            insert()
            loadtable()

        Catch ex As Exception
            Notenrolled.Show()
        Finally

            con.Dispose()
            con.Close()
        End Try

    End If

End Sub

Public Sub loadtable()

    con = New MySqlConnection
    con.ConnectionString = "server=localhost;userid=root;password=1234;database=dat"
    Dim SDA As New MySqlDataAdapter
    Dim dbDataset As New DataTable
    Dim bSource As New BindingSource


    Try

        con.Open()
        Dim query3 As String

        query3 = "select studtags,idno,lastxt,firstxt,middletxt,dob,log,timein,crse from dat.studlogs"
        cmd = New MySqlCommand(query3, con)
        SDA.SelectCommand = cmd
        SDA.Fill(dbDataset)
        bSource.DataSource = dbDataset
        DataGridView1.DataSource = bSource
        SDA.Update(dbDataset)
        DataGridView1.Sort(DataGridView1.Columns(8), System.ComponentModel.ListSortDirection.Ascending)
        If dbDataset.Rows.Count > 0 Then
            logins.Text = table2.Rows.Count.ToString()
        End If


        con.Close()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        con.Dispose()
    End Try
End Sub

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


    loadtable()
    ''Date Now
    Timer2.Start()


    Try
        DataGridView1.AllowUserToAddRows = False ' Disabled or hide (*) Symbol...

        DataGridView1.RowHeadersVisible = False 'To hide Left indicator..
        DataGridView1.DefaultCellStyle.SelectionBackColor = Color.SteelBlue  'Selection backcolor....
        DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGoldenrodYellow 'Alternating Backcolor.
        DataGridView1.AllowUserToResizeRows = False 'Disabled  row resize...
        DataGridView1.ReadOnly = True
        DataGridView1.MultiSelect = False
        DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
        DataGridView1.ShowRowErrors = False
        DataGridView1.ShowCellErrors = False


        table2.Columns.Add("Student Tag", Type.GetType("System.String"))
        table2.Columns.Add("Student ID", Type.GetType("System.Int32"))
        table2.Columns.Add("Last Name", Type.GetType("System.String"))
        table2.Columns.Add("First Name", Type.GetType("System.String"))
        table2.Columns.Add("Middle Name", Type.GetType("System.String"))

        table2.Columns.Add("Status", Type.GetType("System.String"))
        table2.Columns.Add("Birthday", Type.GetType("System.String"))
        table2.Columns.Add("Time in", Type.GetType("System.String"))
        table2.Columns.Add("Course/Sec", Type.GetType("System.String"))


    Catch ex As Exception

    End Try


Merge specific Column from multiple workbook into one work book

$
0
0
I have 10 excel workbook in a folder that I want to combine into one file. The problem is that these files contains more than 30 columns of extra data, that I do not need.
Further complicating things is that the column positions differ between workbooks and workbooks have differing number of columns. I want to create a macro that will go through and open each file, search for the columns I need, and then copy those columns of data and combine them into one master file.

For Ex. I have attached some sample files in that files contains some columns
in that i need to find ID header column on workbook 1 and copy to A column in Master file again find Password on workbook 1 copy the column and paste to B column in master file.
same like that on each file.
Sample.zip


Please anyone Help me.

Thanks in advance
Attached Files

VS 2013 help in api mouse

$
0
0
hello
how use curve in ruler mouse
like this
Name:  aaaaaaaaaa.jpg
Views: 33
Size:  38.5 KB
Attached Images
 

Complex issue - setting multple of the same processes into different panels

$
0
0
Hi all,

I have 10 panels (panel1, panel3, panel5, panel7... panel19) These panels are arranged on a form in the exact same location, of the exact same size (on-top of one another, all originally set as "Visible = False ()")
These panels are all used for housing the exact same process (as child).

I've created a kind of unconventional tab control, whereby the user may "add" another one of these children (by, firstly, making the corresponding panel visible, secondly, bringing it forward, thirdly, starting the process, fourthly, setting the process as a child) The "added" panel containing the child may be viewed within the drop-down menu of a toolstripmenuitem (later I will add a way to navigate through the panels).

Here is the code that adds the menu items relating to each panel that becomes visible when clicking the button:

Code:

    Dim count As Integer = 1
    Private Sub AddProccess_Click(sender As Object, e As EventArgs) Handles AddProcessBtn.Click

        If count <= 10 Then ' This limits the amount of items that can be added to 10

            Dim item As New ToolStripMenuItem
            item.Name = "ChildWindow" & count & "ToolStripMenuItem"
            item.Text = "ChildWindow " & count

            count += 1

            ChildrenViewerToolStripMenuItem.DropDownItems.Add(item) ' This relates the the drop-down items that are added when the button is clicked
            Dim value1 As Integer = ChildrenViewerToolStripMenuItem.DropDownItems.Count
            ChildrenViewerToolStripMenuItem.Text = "ChildWindow (" & value1 & ")"

' This makes it so that if the item is added to the ViewerMenu, and there is 'x' of the item, then this will happen
            If count = 1 Then Panel1.Visible = True
            If count = 1 Then SetChildTimer1.Start()
            If count = 1 Then Panel1.BringToFront()
            If count = 1 Then Process.Start("FilePath of the process (hereby know as "^")")

            If count = 2 Then Panel3.Visible = True
            If count = 2 Then SetChildTimer2.Start()
            If count = 2 Then Panel3.BringToFront()
            If count = 2 Then Process.Start("^")

            If count = 3 Then Panel5.Visible = True
            If count = 3 Then SetChildTimer3.Start()
            If count = 3 Then Panel5.BringToFront()
            If count = 3 Then Process.Start("^")

            If count = 4 Then Panel7.Visible = True
            If count = 4 Then SetChildTimer4.Start()
            If count = 4 Then Panel7.BringToFront()
            If count = 4 Then Process.Start("^")

            If count = 5 Then Panel9.Visible = True
            If count = 5 Then SetChildTimer5.Start()
            If count = 5 Then Panel9.BringToFront()
            If count = 5 Then Process.Start("^")

            If count = 6 Then Panel11.Visible = True
            If count = 6 Then SetChildTimer6.Start()
            If count = 6 Then Panel11.BringToFront()
            If count = 6 Then Process.Start("^")

            If count = 7 Then Panel13.Visible = True
            If count = 7 Then SetChildTimer7.Start()
            If count = 7 Then Panel13.BringToFront()
            If count = 7 Then Process.Start("^")

            If count = 8 Then Panel15.Visible = True
            If count = 8 Then SetChildTimer8.Start()
            If count = 8 Then Panel15.BringToFront()
            If count = 8 Then Process.Start("^")

            If count = 9 Then Panel17.Visible = True
            If count = 9 Then SetChildTimer9.Start()
            If count = 9 Then Panel17.BringToFront()
            If count = 9 Then Process.Start("^")

            If count = 10 Then Panel19.Visible = True
            If count = 10 Then SetChildTimer10.Start()
            If count = 10 Then Panel19.BringToFront()
            If count = 10 Then Process.Start("^")

        End If

    End Sub

So, what do the "SetChildTimer_"'s do? Well, the application that I'm opening is actually quite complex in that it runs off of two processes, the first one is a splashscreen (which, as you'll see in the code below), I chose to hide. The second process that 'does its thing' once the splashscreen has concluded, is the main window that I want, which I have maximized once it is found (the timers are set to an interval of 10ms to search for these processes and set them as child).

Here's the code for setting the children windows:

Code:

    ' #1

    Private Sub Win1SetChildLoader(sender As Object, e As EventArgs) Handles SetChildTimer1.Tick

        Dim LoaderProcess As Process = Process.GetProcessesByName("splashscreen").FirstOrDefault

        If LoaderProcess IsNot Nothing Then

            SetParent(LoaderProcess.MainWindowHandle, Panel1.Handle)
            ShowWindow(LoaderProcess.MainWindowHandle, SW_HIDE)

        End If

    End Sub

    Private p As Process = Nothing

    Private Sub WinSetChildMain(sender As Object, e As EventArgs) Handles SetChildTimer1.Tick

        p = Process.GetProcessesByName("mainwindow").FirstOrDefault

        Dim r As New RECT

        If p IsNot Nothing Then

            GetWindowRect(p.MainWindowHandle, r)
            SetParent(p.MainWindowHandle, Panel1.Handle)
            SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

        End If

    End Sub

    ' #2

    Private Sub Win2SetChildLoader(sender As Object, e As EventArgs) Handles SetChildTimer2.Tick

        Dim LoaderProcess2 As Process = Process.GetProcessesByName("splashscreen").FirstOrDefault

        If LoaderProcess2 IsNot Nothing Then

            SetParent(LoaderProcess2.MainWindowHandle, Panel3.Handle)
            ShowWindow(LoaderProcess2.MainWindowHandle, SW_HIDE)

        End If

    End Sub

    Private p2 As Process = Nothing

    Private Sub Win2SetChildMain(sender As Object, e As EventArgs) Handles SetChildTimer2.Tick

        p2 = Process.GetProcessesByName("mainwindow").FirstOrDefault

        Dim r2 As New RECT

        If p2 IsNot Nothing Then

            GetWindowRect(p2.MainWindowHandle, r2)
            SetParent(p2.MainWindowHandle, Panel3.Handle)
            SendMessage(p2.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

        End If

    End Sub

' ^^ 8 more of these to make 10, I just haven't witten them yet


    ' Correct focusing - This ensures that the form remains in focus when interacting with the child, I think


    Protected Overrides Sub WndProc(ByRef m As Message)

        If m.Msg = WM_ACTIVATE Then

            SendMessageW(Me.Handle, WM_NCACTIVATE, 1, 0)

            If p IsNot Nothing AndAlso Not p.HasExited Then

                SendMessageW(p.MainWindowHandle, WM_NCACTIVATE, 1, 0)

            End If

            m.Result = CType(0, IntPtr)
            Return

        End If

        MyBase.WndProc(m)

    End Sub

Now, what's my problem?
Well, the first window that I "add" (making the count 1, and therefore activating the SetChildTimer1), works perfectly - it starts, the timer detects the process "splashscreen" and then sets it as a HIDDEN child, once the "mainwindow" starts, that's set as "MAXIMIZED" in the panel.
However, when it comes to opening another of the processes (don't forget, they are the same processes), It doesn't add as child (while the other one (count 1) is happily set as child).

I figured that the problem is that the SetChildTimer sub gets confused as to which process to add, since the other one's already running, and tries to add that one. But I'm unsure.

So, how can I make it so that (I guess) the timer sub that sets the processes as children, can tell if it's trying to set a process as child that's already set as child in the previous panel?

I hope this is detailed enough, I always worry it's not. :P

Thanks so much for your help, seriously, thank you a million times over!
Luceee

Get UserControl handle?

$
0
0
Is there a way to recover the handle to a UserControl on a running program? FindWindowEx seems to only return standard VB Class handles.

J.A. Coutts

Object Reference Error Help

$
0
0
Hi, need a little help with this error:

Code:

Private Sub rbs_CheckedChanged(sender As Object, e As EventArgs) Handles rb4.CheckedChanged, rb3.CheckedChanged, rb2.CheckedChanged, rb1.CheckedChanged
        'when we call LoadQuestion we don't want any of these events to trigger
        If Not updatingQuestion Then
            Dim rb = DirectCast(sender, RadioButton)
            Dim qandaAnswer = curQandA.Answers.Where(Function(a) a.AnswerText = rb.Text).FirstOrDefault 
            For Each ans In curQandA.Answers
                If ans Is qandaAnswer Then
                    ans.AnswerChecked = True
                Else
                    ans.AnswerChecked = False
                End If
            Next

I get object reference not set to an instance of an object at the highlighted line

Thanks

Logging in and creating accounts (hashing)

$
0
0
Hi

I'm starting a project to basically practice this technique and am starting of by making a tool that creates useraccounts that an admin user would use.

This is a desktop App and basically all i have right now is an Azure DB, and some functionality to view an accounts table, and created a Stored Procedure to add an account, its pretty basic right now but im a little confused about the best process/practice here......

the current process im working on is as follows.

1, create a new user with username and password on the tool
2, Hash the password on the App
3, Send the details to the stored procedure (using sqlConnection class)
4, perform username checks etc and make sure there are no other users with this name
5, hash the password again using crypto created salting (hash is SHA2_512, salting is 64bits)

so im wandering, im just going to hash stage 2 using maybe the username as salt...... this should be fine right?
im also wandering when actually logging in just following the same process will work but is what im doing going to be effective just for a desktop app?

im new to all this and today is my first day at trying this out, i think what im doing will work im just wandering if its going to be secure :D

[RESOLVED] how do i remove duplicate data while looping through a listview

$
0
0
hey,
i have a code that i loop through a listview
what i want to do is to remove any duplicates names
something is missing there in my code.
Code:

    Dim A As Integer
    Dim B As Integer
    For A = 1 To LsVw.ListItems.Count
        For B = 1 To LsVw.ListItems.Count
            If A <> B Then
                If LsVw.ListItems(A).Text = LsVw.ListItems(B).Text Then
                    LsVw.ListItems.Remove
                End If
            End If
        Next
    Next

tnx for any help
salsa :)

DataReport data type - missing properties

$
0
0
Hello

VB6 SP6.

Create a new DataReport, let's call it Foo.
You can do this:
Code:

Debug.Print Foo.WindowState
If you open Foo, you will see in the Properties window's title "Foo DataReport", and it has a WindowState property. All good so far.

Now,
Code:

Dim rpt As DataReport
Set rpt = Foo
Debug.Print rpt.WindowState

Quote:

Compile error:
Method or data member not found.
So Foo is a DataReport and so is rpt, and they're same same but different.

I need to be able to "Dim rpt as Foo" and be able to set the same properties that Foo has. How do I do that?

Hi friends

$
0
0
Hi friends,

This is Jean, new member of this forum. I'm here to gain some development knowledge and share what I know.

Hope all of my friends will help to continue discussion.

Thanks,

HTML/CSS - Table - always more than expected

$
0
0
Hi

I'm using Bootstrap to limit columns etc. but I seem to be having a problem in how the browser calculates what it can display?

up to the point I put a table in, it seems to work fine, getting the widths properly, using overflow to hide or scroll etc.
But as soon as I put a table in with a % defined width, the tables calculated width gets propogated up through the parents. This messes with the %...
So either its something that is always there or I'm missing something.

Any pointers?

I've already read this table layout...

VS 2010 Populating Blob type Images to Datagridview vb.net

$
0
0
The Data from my sql is already populated in the Datagridview, my only concern is how to put that Image from mysql to the row or cell including the data which is already populated just only the Image I want to display too. They said that System Drawing may be a help too but I don't have any Idea Thanks for advance..

My code
Code:

Public Sub loadtable()



    con = New MySqlConnection
    con.ConnectionString = "server=localhost;userid=root;password=1234;database=dat"
    Dim SDA As New MySqlDataAdapter
    Dim dbDataset As New DataTable
    Dim bSource As New BindingSource


    Try

        con.Open()
        Dim query3 As String

        query3 = "select studtags as 'Student_Tag',idno as 'Student_ID',lastxt as 'LastName',firstxt as 'FirstName',middletxt as 'MiddleName',dob as 'DateofBirth',log as 'Status',timein as 'Timein',crse as 'Course',studpic from dat.studlogs"
        cmd = New MySqlCommand(query3, con)
        SDA.SelectCommand = cmd
        SDA.Fill(dbDataset)
        bSource.DataSource = dbDataset
        DataGridView1.DataSource = bSource
        SDA.Update(dbDataset)

        DataGridView1.Sort(DataGridView1.Columns(7), System.ComponentModel.ListSortDirection.Descending)


        If dbDataset.Rows.Count > 0 Then
            logins.Text = dbDataset.Rows.Count.ToString()
        End If


        con.Close()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        con.Dispose()
    End Try
End Sub

Enhance links .. add underline

$
0
0
Just setting the font to blue is sometimes hard to interpret as a link ..

Name:  vbfeedback14.png
Views: 34
Size:  12.3 KB

Here is where it came from.

As you can see, I manually added the Underline tags.
It "pops".

Could you guys make that automatic?

EDIT-1

BTW, I've noticed that Elroy already does this.
Sadly, very few others do, and it's often hard to discern that a link is involved

Spoo
Attached Images
 

Automation Error Element not found. VB6

$
0
0
I'm getting an error "Automation Error Element not found" in vb6 when I'm trying to open "DataEnvironment", What's this error and how can I rectify it?

Just Wondering how i would do this.

$
0
0
Hello Again, I am working on this application that records the use of Rolls being used on a production line to a Access Database. On Monday two new rolls will be added to the production line one to Station 1 and one to Station 2. So i have just been told.

At the moment when the Start Button is pressed the time is added to the dark blue line at the bottom and it's added to the Database. After the time is added a form comes up asking for details of the previous Roll that populates the yellow Row and fills in the four cells that are empty.

Name:  Sample1.jpg
Views: 44
Size:  10.1 KB

Then with the yellow line populated it allows another Roll to be added which in turn adds Roll information to a new line to repeat the process over and over.

I get that working great then i have been asked to then change the approach to how this all gets started..

The suggestion is to have both stations waiting in the database to be started. Then ask the user which one they are starting Station 1? or Station2? From a form they pick a station to start and from there ongoing to do the above. Would it be possible to swap the rows round if say the one before the last was chosen to maintain the current workflow.

Can anyone think of a way this can be achieved or if i am making this hard work... The DataGridview is bound to the dataset. Any ideas would be greatly appreciated.

Thank you. I can give code of what i have done so far but really don't know if i have approached it in the right way.
Attached Images
 

VS 2017 UDP Multicast Not Sending Packets

$
0
0
Hi,

I have a light bulb that needs a specific multicast UDP packet sent to discover whether any exist on the network (it is similar to SSDP but on a different port and none of the third party libraries work with it, so I'm going to have to roll my own).

I've read the .net SDK for the UDPClient and it is simply not working in the way it seems to say, at it's simplest to send the string I have;

Code:

Dim IP As IPAddress = IPAddress.Parse("239.255.255.250")

Dim uClient As New UdpClient(1982)

uClient.JoinMulticastGroup(IP)

Dim RemoteEndPoint As New IPEndPoint(IP, 1982)

Dim senddata As Byte()

Dim query_str As String = "M-SEARCH * HTTP/1.1" & vbCrLf & "HOST: 239.255.255.250:1982" & vbCrLf & "MAN: ""ssdp:discover""" & vbCrLf & "ST: wifi_bulb" & vbCrLf

senddata = Encoding.UTF8.GetBytes(query_str)

uClient.Send(senddata, senddata.Length, RemoteEndPoint)

Which to me should attempt to join the multicast IP, then set up the end point and then send the string of data (I'll cross receiving the data later). Whatever I do does not send the data (I am monitoring using Wireshark), if I swap the IP for a local IP then it sends the data just fine, if I use a third party discovery tool (sadly no source code) on the PC it works fine which says to me that the problem is in my coding rather than anything like router settings, firewalls etc have been disabled.

The .net SDK seems to say "You do not need to belong to a multicast group to send datagrams to a multicast IP address." which I have tried doing by dropping the .joinmulticast but that seems to have no effect and it still does not send the packet. As far as I can see I am doing everything I should (setting up the UDP client with a port parameter) but it appears the moment I put a multicast IP in it fails to resolve. The address is valid for the range and it does not throw any exceptions, it just does not send it?

Does anyone please have any ideas what I can try? I am compiling for .net 4.6 but have tried 4.0 and no difference.

Thanks,

XOR Checksum for High And Low Byte

$
0
0
Dear All Master,

I need your help, below are the problem i facing and i have no idea how to get start

i'm using serial communication connected with a machine and i was receive a block message such as

Quote:

! ./H|\^&
P|1||617013597||MUHAMMAD^SHAFIQ^IKHWAN|||||||||||||||||||||||||||
O|1|W2|||||20171024074000
R|1|^^^449261136087^92|BACT%-
the part that i bold %- is the checksum for the block of text

in the document is was describe that the checksum is usinng XMODEM Rules

Quote:

With the translation enabled the communications packet would appear as follows:
<SOH><BSN1><BSN2><CBSN1><CBSN2><--- 128 data bytes --- ><CHK1><CHK2>
Becton Dickinson's implementation of the protocol makes use of the translation process for
the BSN, CBSN and the CHK characters. If you are implementing the protocol to interface
with one of Becton Dickinson's instruments, the translation process must be included in the
implementation.
i know how to get the single checksum for XOR but when come to High and Low ... i have no idea...
CHK1 is Checksum in High Byte and CHK2 is Low Byte..

i need to know how to calculate the CHK1 and CHK2 when i return block message back to the machine.

How to draw a waveform graph from mp3 or wav?

$
0
0
I'm trying to draw a waveform graph from mp3 or wav files.

I read Olaf and TheTrick's source code, but I haven't found the answer yet.

I searched for some code on the PsCode and vbAccelerator, but the code was too old to even open a wav file.

Does anyone know how to draw a waveform? I really appreciate any help you can provide.
Attached Images
 

How to create a query with columns from two tables

$
0
0
OK i have two tables one is called Book Table and has these attributes ,Book Name, Author, ISBN, Book condition,Genre,Copies)

the second table is called Reservation table and has these attributes (Reserver ID(PK), Reserver Name, Book ID(FK), Book Name, Check out date, Due date, Return date)

I want to make a query of the two tables but i only want the query to displays the Book name, Book ID, Author Reserver name,Reserver ID [/COLOR]For the Books that are being reserved in the Reservation table. For example if a book in my book table has the Book ID of 1 and i enter this Book ID in my reservation table (which is a foreign key in this table) i want the query to only displays the information of the book with that Book iD along with the reserver name and reserver ID. This way i can see the reserver name,reserver ID,Book Name,Book ID, and Author in one row. <~~this will be the person who reserved the book and some of the attributes of the book which are the Book Name, Book ID, and author.


I am using a sql table in visual basic

VS 2012 Creating a query to retrieve database table

$
0
0
I want to write a database query to retrieve a table then fill it in a datagridview but I''ve tried but this's all I got
Code:

Imports System.Data.SqlClient
Module Personal_PrivateModule
    Public databaseLocation As String = Nothing 'the location is gotten from an open file dialog
    Dim Connection As SqlConnection
    Dim Command As SqlCommand
    Dim Reader As SqlDataReader
 
    Public Sub Connect()
        Try
            DatabaseSelect.ShowDialog()
            Dim ConnectionString As String = "Data Source=(LocalDB)\v11.0 ;AttachDbFilename=" & databaseLocation & ";" & "Integrated Security=True;Connect Timeout=30"
            Dim Connection As New SqlConnection(ConnectionString)
            Connection.Open()
            If ConnectionState.Open Then
                MsgBox("Connection Established...")

                Connection.Close()
                MsgBox("Connection Closed...")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

End Module

Viewing all 42106 articles
Browse latest View live


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