Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

sohaib_a

@sohaib_a
About
Posts
48
Topics
20
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Cant find SQL ServerCE.dll
    S sohaib_a

    I have device running Windows CE 5.0. I am developing an application for it in C# using a SQL server mobile database. In order to install the database on the device,I first have to add SQLserverCE.dll.But I don't know why the folder or dll is not available. I tried to install Microsoft SQL Server Mobile Developer Tools.but still nothing. I also reinstalled SQl Server 2005...

    C# database csharp sql-server sysadmin tools

  • SQLServerCE.dll
    S sohaib_a

    I have device running Windows CE 5.0. I am developing an application for it in C# using a SQL server mobile database. In order to install the database on the device,I first have to add SQLserverCE.dll.But I don't know why the folder or dll is not available. I tried to install Microsoft SQL Server MObile Developer Tools.but still nothing. I also reinstalled SQl Server 2005...

    Database database csharp sql-server sysadmin tools

  • Cant find SQLServerCE dll
    S sohaib_a

    I have device running Windows CE 5.0. I am developing an application for it in C# using a SQL server mobile database. In order to install the database on the device,I first have to add SQLserverCE.dll.But I don't know why the folder or dll is not available. I tried to install Microsoft SQL Server MObile Developer Tools.but still nothing. I also reinstalled SQl Server 2005...

    Hardware & Devices database csharp sql-server sysadmin tools

  • How to check if TCP/IP connection is active with a device
    S sohaib_a

    i know but ping will only tell if the device is connected to the network..it will not tell me if there is an active connection(ie that there is some data flow between the device & pc). For instance the device is connected to my application(i can ping it as well)...however if i pull out the cable and plug it in back again..i can still ping it...but it isn't connected to my application anymore...so the ping check is not enough for this..it wont tell me if it is connected or not..is there some way to do this with sockets and ports?

    Visual Basic sysadmin json tutorial

  • How to check if TCP/IP connection is active with a device
    S sohaib_a

    Hey.. I really at my wits end on this. I have a device that i connect to through TCP/IP using an api function call. Because there could be cases where maybe the router/switch restarted or the network went down or something and if this happens then the device should connect automatically again. I need a to check the the connection status of the device,whether it is connected to application or not so then i can reconnect automatically. I did something like this

    Dim information As TcpConnectionInformation
    For Each information In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
    If (information.RemoteEndPoint.Address.ToString = readerIp) Then
    state = CInt(information.State)
    End If
    Next

    However this updates the state only after i manually disconnect the device.It the i pull the cable out and plug it back in it still show the same state. Is there another way to this,to check where a connection is..(not like ping) but if there is an active connection between the device and pc.

    Visual Basic sysadmin json tutorial

  • Handling Exceptions In Threads
    S sohaib_a

    Thanks guys I will try your way and see what happens. Sorry Luc but I had forgot to mention in the example,I have put a error log entry that writes to a text file in the catch block,but the thing is when the exception is thrown it never goes to the catch block.The thread then just dies.I never know that the socket exception occurred. I can only seem to catch the Thread Abort Exception in the thread.I am not sure but I had read this article somewhere on the net that only Thread Abort Exception can be handled in background threads.Thought you guys could give me more info on this.

    Visual Basic design json help question lounge

  • Handling Exceptions In Threads
    S sohaib_a

    I didnt understand exactly what you mean.. This is how I am doing it the threading way. Public Sub somfunction() '''I make all the thread declarations (address of startthread) Thread.start() End Sub Public Sub startthread Try ''''APi function call to connect to device --this throws a socket exception when the device is not available but i cannot catch this exception.It throws the exception but it doesn't go to the catch block. catch ex as exception End try End sub But when I do it on the main thread (on the form) Public sub somfunction Try ''API function call----this socket exception is caught Catch ex as exception End try End Sub End Sub

    Visual Basic design json help question lounge

  • Handling Exceptions In Threads
    S sohaib_a

    I have an application in which i create a thread to run a certain process. There is a api function call in the thread that tries to connect through TCP/IP to a device and get some data from it.If the device is disconnected then I get a socket exception. I need to handle this exception however I found out during debugging that even though the exception was thrown,it went unhandled even though I put a try catch block. However when i run it on the Main UI thread everything is fine. After doing some searches on this issue I have understood that general exceptions cannot be handled in threads?Is this correct? If so,is there a way to handle this socket exception?If any one has any idea about this or can direct me to any good articles on this...really appreciate it..

    Visual Basic design json help question lounge

  • Change the size od MDI container in the parent form
    S sohaib_a

    Is this the way you mean,but it's not working.When maximize the parent form,the child form maximizes to the entire form.What is the problem? For Each ctrl As Control In Me.Controls If TypeOf ctrl Is MdiClient Then ctrl.Dock = DockStyle.None ctrl.Location = New System.Drawing.Point(1, 107) ctrl.Size = New System.Drawing.Size(769, 434) End If Next

    Visual Basic docker question

  • Change the size od MDI container in the parent form
    S sohaib_a

    Hello, How can you change the size of the MDI container in a MDI parent form?

    Visual Basic docker question

  • Problem with restarting thread
    S sohaib_a

    I have function 'startthread' that points to the thread 'thread1' which is started when I click on button1. When i click on button2,it is supposed to stop the thread.I want to restart the thread1 but when i click on button 2 again it gives ThreadStateException saying 'Thread is running or terminated; it cannot restart' What am i doing wrong here?

    ''To Start the thread
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim ds1 As New DataSet
    Dim i As Integer = 0
    ds1 = clsDB.getData("Select * from Readers_test")

        Dim s As String = ds1.Tables(0).Rows(0)("Reader\_Name").ToString + ":" + ds1.Tables(0).Rows(0)("IP\_Address").ToString + ":" + ds1.Tables(0).Rows(0)("Port\_No").ToString
    
        'thread1.IsBackground = True
        thread1.Start(s) ''I get exceptio here when I try to restart the thread
    
    End Sub
    

    ''To Stop the thread

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        api.TcpCloseConnect()
    
        If thread1.IsAlive Then
            thread1.Abort()
        End If
        setValue(Me.TextBox3, "Stopped")
    End Sub
    
    
    
    
    Private Sub startthread(ByVal state As Object)
      
    
        Dim timer1 As New System.Timers.Timer
        AddHandler timer1.Elapsed, AddressOf scan
        Dim st As String = state
    
        Dim status As Integer = 2
        Dim param\_arr() As String = st.Split(":")
        Dim Location As String = param\_arr(0)
        Dim ReaderIP As String = param\_arr(1)
        Dim Port As String = param\_arr(2)
        Dim ReaderPort As Integer = Integer.Parse(param\_arr(2))
    
        
        status = api.TcpConnectReader(ReaderIP, ReaderPort)
    
        If status = 0 Then
           
    
            setValue(Me.TextBox1, "Connected")
    
            api.ClearIdBuf()
            timer1.Interval = 1000
            loc = Location
    
            clearbuf = 0
            timer1.Start()
        Else
            setValue(Me.TextBox1, "Not Connected")
    
        End If
    
    End Sub
    
    
    Public Sub scan(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
    
        Dim status As Integer = 2
        Dim i As Integer, j As Integer
        Dim IsoBuf As Byte(,) = New Byte(99, 13) {}
        Dim tag\_cnt As Byte = 0
        Dim s As String = ""
        Dim s1 As String = ""
        Dim antno As Integer = 5
        Dim tagstatus As String
    
    Visual Basic json help question

  • refresh datagrid on another windows form
    S sohaib_a

    Thanks...

    Visual Basic database announcement

  • refresh datagrid on another windows form
    S sohaib_a

    how..what do you mean..haven't i used that already?

    Visual Basic database announcement

  • refresh datagrid on another windows form
    S sohaib_a

    I have two forms in my application.On form1 there is datagridview -dg1 which is filled with a dataset-ds1. On form2 I have a some code ,which after fulfilling certain conditions updates the database table which is contained in ds1. When this is done I want to refresh datagridview-dg1 and show the updated table. Both the forms are already open and I have to update them.

    Form2

    Public Event refreshdg1(ByVal st As String)

    Private Sub

    .......Some condition -->True then
    ....... Update database table

    'I tried three ways here

    1- Raiseevent refreshdg1(s1)

    2-

        Dim StrCon As String
        Dim conn As SqlConnection
        StrCon = ConfigurationManager.AppSettings("StrCon")
        conn = New SqlConnection(StrCon)
        conn.Open()
       Dim ds As New SqlDataAdapter("Select \* from Tag\_History where Tag\_ID = '" + s1 + "' ", conn)
      Dim commandBuilder As New SqlCommandBuilder(listadapter)
    
      Dim table As New DataTable()
    
      table.Locale = System.Globalization.CultureInfo.InvariantCulture
     listadapter.Fill(table)
    
     Form1.dg1.DataSource = table
     conn.Close()
    

    3- Form1.refreshdg(s1)

    End sub

    Form1:

    Addhandler Form2.(I cant refreshdg1 here)

    Private Sub refreshdg(ByVal s As String)
    Dim f As New Parking_control
    AddHandler f.refreshdg1, AddressOf refreshdg
    Dim StrCon As String
    Dim conn As SqlConnection
    StrCon = ConfigurationManager.AppSettings("StrCon")
    conn = New SqlConnection(StrCon)
    conn.Open()

        Dim person As String
        person = s
    
        Dim ds1 As New SqlDataAdapter("Select \* from Tag\_History where Name = '" + person + "' ", conn)
        Dim commandBuilder As New SqlCommandBuilder(ds1)
    
    
        Dim table As New DataTable()
    
        table.Locale = System.Globalization.CultureInfo.InvariantCulture
        listadapter1.Fill(table)
        table.Columns(0).ColumnName = "Tag ID"
        table.Columns(1).ColumnName = "Date   Time"
        table.Columns(3).ColumnName = "Tag Status"
        dg1.DataSource = table
    
        conn.Close()
    
    End Sub
    
    Visual Basic database announcement

  • passing parameter in system.threading.timer
    S sohaib_a

    thanks alot.that worked, Dim s as string m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), s, 1, 5000) in the timer callback method... Private Sub timer1_tick(ByVal state As Object) Dim st As String = state End Sub NO casting...what is it used for anyway?

    Visual Basic question data-structures

  • passing parameter in system.threading.timer
    S sohaib_a

    I am still not getting it...dont know how to adapt the example for my case. Private Sub timer1_tick(ByVal state As Object) Dim j As String = DirectCast(state, String) End Sub this gives an error.

    Visual Basic question data-structures

  • passing parameter in system.threading.timer
    S sohaib_a

    I have an application in which i want to run multiple threads periodically.For this i am using the system.threading.timer in an array. When i start the timer i also want to pass a string as a parameter to the timer callback method.There is a parameter; 'state as object'.Can i pass the the string through this?

    For j As Integer = 0 To m_TimerList.Count - 1
    'Dim oCallback As New TimerCallback(AddressOf timer1_tick)
    Dim s As String = "1"
    m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), New Object() {s}, 1, 5000)
    k = k + 1
    Next

    How do i get the string in the timer callback method 'timer1_tick'

    Visual Basic question data-structures

  • Modifying a window service
    S sohaib_a

    I have a windows service coded in vb.net running.This service is controlling several devices simultaneously.Now i want to add another device to the system.How is it possible to do this without stopping the service or changing the code?Can it be done dynamically?

    Visual Basic csharp question

  • Passing arguments to timer event
    S sohaib_a

    Yes there is a timer inside the worker which is started in the worker's dojob event as shown in the code i posted earlier. Ok..so is a class variable something like a global variable?And after i pass the string to worker's DOJOB event,i should declare at is a class variable in the DOJOB? Do you have any examples for this? All the workers will be running in parallel,so will there be multiple instances of this string each with it own value relative to the back ground worker it was passed from?

    Visual Basic question

  • Passing arguments to timer event
    S sohaib_a

    Ok. Well the strings are stored in a database.Each background worker will take a different string depending on input from user. This is how i am doing it.

    If reading <= m_WorkerList.Count - 1 Then

          str = ds1.Tables(0).Rows(0)("ReaderLocation").ToString
    
        status = api.TcpConnectReader(ds1.Tables(0).Rows(0)("ReaderIP").ToString, \_
                 ds1.Tables(0).Rows(0)("ReaderPort"))
    
               If status = 0 Then
    
            api.TcpCloseConnect()
            st = str
    
            m\_WorkerList(reading).RunWorkerAsync(str)
    

    reading = reading +1
    End If

    m_Workerlist is a list of BGW that i have initailized earlier.

    Visual Basic question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups