M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok lets assume if we have two textboxes , txt1 and txt2 , i want to get control on txt2 if i press enter and also got control txt1 if i press enter in txt2 , use this code

'---use this code at the keypress event of the control .
if e.keychar = chr(keys.enter) then 
'write the name of your control where you want to get focus like this 
txt2.focus() 
end if

regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

this thread is now going very long , even when you got solution of your first prob. please always use next thread for your next prob. so that others can also participate in giving solution.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

this is the best site to learn .net http://msdn.microsoft.com/library/default.aspx, this site will help you alot if you want to learn .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

if your prob is solved , please mark this thread solved.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i dont know the reason why this is happening , to trace error , please use try catch block , and for now you can use textbox with multiline true property , to save huge text.
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

first the datatype of your field is bit , then use above mentioned code to save the value of your radio button.

radiobutton1.checked

regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

if you are using access , then this is the same logic , which you need, so before writing code it is imp to know what you need to do to complete your task , if you need any other information then please also do tell .

GOD Bless you,

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you want to insert records in db , there are some steps you have to follow.
1-you have to import class at the top of your form .here is the code

import system.data.sqlclient
'NOTE:please type this code at the top .

after doing this , you have to understand little bit about the components you will use for inserting records.
--SqlConnection - it is used to connect your application with your database.
--sqlCommand - Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database.
--Connection String -A connection string is a string version of the initialization properties needed to connect to a data store and enables you to easily store connection information within your application or to pass it between applications.
now here is code and step by step description .

'after importing system.data.sqlclient
'we have to connect our application with db , for this we use connection string ,
'Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
'above is a connection string 
'now start connection
dim myCon as new sqlconnection("Data Source=waqas/sqlexpress;Initial Catalog=myDataBase;Integrated Security=SSPI;")
'here you have to give your server , and your database name ,as i give.
'after connection there are two states of your connection , a open state and close state.
'now we make a insert command to insert records in database.
dim cmd as new sqlcommand
'now set your connection open 
myCon.open()
cmd.connection = myCon
'here we make a command
cmd.commandtext = "insert into table …
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you want to insert records in db , there are some steps you have to follow.
1-you have to import class at the top of your form .here is the code

import system.data.sqlclient
'NOTE:please type this code at the top .

after doing this , you have to understand little bit about the components you will use for inserting records.
--SqlConnection - it is used to connect your application with your database.
--sqlCommand - Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database.
--Connection String -A connection string is a string version of the initialization properties needed to connect to a data store and enables you to easily store connection information within your application or to pass it between applications.
now here is code and step by step description .

'after importing system.data.sqlclient
'we have to connect our application with db , for this we use connection string ,
'Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
'above is a connection string 
'now start connection
dim myCon as new sqlconnection("Data Source=waqas/sqlexpress;Initial Catalog=myDataBase;Integrated Security=SSPI;")
'here you have to give your server , and your database name ,as i give.
'after connection there are two states of your connection , a open state and close state.
'now we make a insert command to insert records in database.
dim cmd as new sqlcommand
'now set your connection open 
myCon.open()
cmd.connection = myCon
'here we make a command
cmd.commandtext = "insert into table …
masood786 commented: so nice of work +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
there is no time to read your full code , please let me know , do you want to know how to insert record in database ?

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
i want to get some information about LAN traffic . in my office there are 15 employees are there , we are connected with modem ,i want to moniter there activities for example which sites they are visiting,uploading , downloading . some one tell me about netstat but this will show the information about my pc.can any one help me in this .

Regards
M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you have to use installer making utility in which you can add two or more then two software to install them as a single setup. here is a link , may be this will solve your prob .
http://www.hlrnet.com/frprinst.htm

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
i tried to make a query which generate the same result as you want , but prob it that the fields Acolumn3 and others have boolean data type which can not be sum , so the result of the query is something like this
COMBINED TABLE
=================================================================================
-ID---NAME---AGE---ACOLUMN3---ACOLUMN4---ACOLUMN5---BCOLUMN3---BCOLUMN4---BCOLUMN5
---------------------------------------------------------------------------------
-1---JON-----23------TRUE------FALSE------TRUE---------------------------------
-1---JON-----23--------------------------------------TRUE------FALSE-------TRUE
-2---JANE----29------TRUE------FALSE------FALSE---------------------------------
-2---JANE----29--------------------------------------FALSE-----FALSE-------FALSE
-4---JOEY----34------FALSE-----FALSE------FALSE--------------------------------
-4---JOEY----34--------------------------------------FALSE-----TRUE--------TRUE
-3---JOE-----32------TRUE------TRUE-------TRUE-----------------------------------
-3---JOE-----32--------------------------------------TRUE------TRUE-------FALSE

here is a query

select id,name ,age ,Acolumn3 ,Acolumn4 ,Acolumn5,'' as Bcolumn3 ,'' as Bcolumn4 ,''as  Bcolumn5
from table_1
group by id ,name ,age ,Acolumn3 ,Acolumn4 ,Acolumn5
union all
select id ,name ,age ,''  ,'' ,'' ,Bcolumn3 ,Bcolumn4 ,Bcolumn5 
from table_2
group by id,name , age ,Bcolumn3 ,Bcolumn4 ,Bcolumn5
order by id

i know this is not what you want , but this is what i can do for you :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you done wrong thing in tick event , you can just check it like this

if Label17.BackColor = Color.LimeGreen then 
' your code 
end if 
' this condition always checked by the timer at its every tick event , now you can just set the interval of your timer as you want.

please if i am wrong then do tell me.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
sorry for late reply , i know thread is solved , but here is a code to remove the unchecked items from checklistbox.

Dim i, ii, b As Integer
        Dim list, list2 As New ArrayList
        'in this loop we only select and add those items in our list those are checked
        For i = 0 To CheckedListBox1.CheckedItems.Count - 1
            list.Add(CheckedListBox1.CheckedItems.Item(i).ToString)
        Next
        'here we are adding items in list2 those are not in list , thats mean we are adding all the items those are not checked
        For ii = 0 To CheckedListBox1.Items.Count - 1
            Dim item As String
            item = CheckedListBox1.Items.Item(ii).ToString
            'this condition checks that is list contains the item , if return false then it will add it in list2
            If list.Contains(item.ToString) = False Then
                list2.Add(item.ToString)
            End If
        Next
        'here i am removing the items of list2 because they are unchecked 
        For b = 0 To list2.Count - 1
            CheckedListBox1.Items.Remove(list2.Item(b).ToString)
        Next

Regards

thehunk commented: nice code , work perfectly . +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

roshu , did you try my method , is it also not working ?

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please change this line

cmd.Parameters.Add("@Telephone", SqlDbType.Int).Value = txtEmpTelephone.Text

with this

cmd.Parameters.Add("@Telephone", SqlDbType.Int).Value = val( txtEmpTelephone.Text)

hope this will solve your prob , if yes then please mark this thread solved.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well @king , there is not that much time i have to read code , i just saw the question , and i reply it , but as you said you also use new key word , but if you use simple way of helping and just keep your code to the point , then it is time saving and easy to understand ,as you write full code twice , that is not imp.

Stay blessed

M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

no it will not effect your result can you please write your query here , so that i can better ans you.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !

'please use new in this line 
 Dim objcmd As OleDbCommand
'----------------------------
'like this 
 Dim objcmd As new OleDbCommand

this will solve your prob .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok you can do like this , use a timer as king said , but do this

' declare a variable 
dim myDelay as boolean = false 

'now here is ur code 
        AxWindowsMediaPlayer1.URL = "c:\vids\a.avi"
        AxWindowsMediaPlayer1.Ctlcontrols.play()
'start your timer here 
timer1.enable = true 
timer .interval = 5000
'use a while loop
while mydelay = false
 End While
label1.text = "finished playing"


'now use this at the timer tick event 
myDelay = true 
timer1.enable = false

this is not a ideal solution , but this will work for you :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i cant understand your prob , please tell me , how you want to compare your date , in your mssql query , or in your form ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well if some one select a value after saving it in database , remove it from combo so that no one can select it again.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

and if you have datatype datetime in your db , then auto time will be added in your records , this will not effect any thing , and you can perform any task.

Regads

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can do like this

datetimepicker.value.date.tostring()
'or you can set format property according to your requirement .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
use this sub

Sub myshow()
        Try
            Dim mycon As New SqlConnection("connection string")
            mycon.Open()
            Dim da As New SqlDataAdapter("select * from table", mycon)
            Dim dt As New DataTable
            da.Fill(dt)
            datagrid1.datasource = dt
            mycon.Close()
        Catch ex As Exception
            MsgBox(Err.Description)
        End Try
    End Sub

this is simple code to populate grid , call this sub after your insert sub , at the insert button click , this will reload your grid , the basic logic is that , after insert a new record , you have to get new records from your db into you datatable so that we can see newly inserted record. hope this will solve your prob .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes , at the top we declare variables , byval fname as string , here you can change string to integer , and also in your for loop where you are getting values from the grid , use val(datagrid.item(0,i).tostring()) , it will work perfectly , but if you have prob with that please post your full code , so that i can better ans you.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello gozo !
can you please rephrase your prob , there is not much time to read another thread to understand your prob , please give full description in order to get quick and good solutions of your prob.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
i think it is not possible in mssql server , you can open it even when your software is running . this is what i think , so dont lose hope , if you find any solution please post it here for others .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok now please use this code to insert your data into db , using grid ,
for example we have two columns , fname , and lname , in grid , and we want to insert them ,

sub myInsert(byval fname as string , byval lname as string)
'in above i declear two variables fname , lname 
Try
dim con as new sqlconnection("you connection string")
dim cmd as new sqlcommand 
con.open()
cmd.connection= con
cmd.commandtext="insert into table (fname,lname) values (@fname,@lname)"
cmd.Parameters.AddWithValue("@fname", fname)
cmd.Parameters.AddWithValue("@lname", lname)
cmd.ExecuteNonQuery()
Con.close()
Catch ex As Exception
MsgBox(Err.Description)
End Try
end sub
'after this sub , you can just call it any where in your form , now after making this sub at top of your form where we declare global variables ,use this code to call it 
dim i as integer
try
for i = 0 to datagrid.rows.count-1 
myInsert(datagrid.item(0,i).tostring() , datagrid.item(1,i).tostring())
'note , you can also give the column name of your grid in place of column index , like this datagrid.item("fname",i).tostring()
next
Catch ex As Exception
MsgBox(Err.Description)
End Try

by using above code you can insert your records in your db .hope this will solve your prob , if yes them please mark this thread solved and vote me up :)

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
simple do this , first assign same datasource which you assign to your grid ,

grid.datasource = datasource 
combobox.datasource = datasource
'now here you can access any column
combobox.displaymember = "fieldname"

hope this will helps you

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can also use loop in order to check each items of the listbox. to gain access. but jim's solution is i think fast .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
as king said that there is no error in your code , the possibility is this that you are using this code in a way that it is executed twice thats why you got two records inserted. and the reason that you insert the record and the most recent inserted record is not shown in grid , is that you are not updating your datasource of your grid , the better way is to make sub() of your grid populating code , and call it just after your insertion code.or you can use binding source , and use this property

bindingsource.movelast()

hope this will gives you an idea .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please can you rephrase your question :( so that i can better help you .
but you can use for loop , for this .but after understanding your issue then i can better answer you.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
try this code , you have to use this code at text change event of your textbox .

Try
            Dim MyCon As New SqlConnection("connectionstring")
            Dim MyDataSet As New DataSet
            MyCon.Open()
            Dim Myquery As String
            Myquery = "select vendorid , vendorname from vendors"
            If TextBox1.Text <> "" Then
                Myquery = Myquery & " where vendorname like '" & TextBox1.Text & "%'"
            End If
            Dim da As New SqlDataAdapter(Myquery, MyCon)
            MyDataSet.Tables("Vendors").Clear()
            da.Fill(MyDataSet, "Vendors")
            DataGridView1.DataSource = MyDataSet.Tables("Vendors")
            MyCon.Close()

        Catch ex As Exception
            MsgBox(Err.Description)
        End Try

Regards :)

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
well try this code ,you have some errors in your code , first , you define dataset , but you had not define a table in it , 2nd one datagrid.items.add(ds) , this is wrong way , if you want to populate the grid then use datasource property , here is a code , hope this will solve your prob

try
dim con as new sqlconnection("Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;")
'now here i am defining a data adapter
con.open
dim da as new sqldataadapter("select * from table",con)
'now m going to define dataset 
dim ds as new dataset 
'here i create a table in it.
        ds.Tables("table").Clear()
'here i fill that table
        da.Fill(ds, "Table")
'here populate the grid
DataGrid1.datasource = ds.tables("table")
con.close
        Catch ex As Exception
msgbox(err.description)

        End Try

this will solve your prob , :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can get current date use now() . like this

Now.Date.ToString()
        Now.TimeOfDay.ToString()
        Now.Year.ToString()
        Now.Month.ToString()

Hope this will help you , :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

sorry i can get your point , you want to show 3 columns in grid like this f_name + m_name + l_name in a single cell , ? and 2nd thing what i understand is that you want to show 3 columns of your grid in a combo in this way f_name + m_name + l_name ,
please rephrase you question.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
please can you tell me , you want to save data from grid , or from your datatable.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes you can do it in this way

Try
            ListBox1.Items.Remove(ListBox1.SelectedItem)
        Catch ex As Exception
            MsgBox(Err.Description)
        End Try

Hope this will Solve your prob .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes it is very simple, for example you have a formA having textbox and formB has a listbox , now put this coding at you button.

Try
            formB.listbox1.items.add(textbox1.text)
        Catch ex As Exception
            MsgBox(Err.Description)
        End Try

this will solve your prob .
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

where we type post there is a link mark this thread solved , click it thread is solved , and please @renzlo that i am just come and got a solved thread , i am just telling him.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

correct syntax of top() is

select top 1 idno from students
order by idno desc

sorry for above wrong code .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can use max() and top() to get the last inserted record in your db table

select max(id) as id from table
'-------------
select top(id) as from table
order by id desc

Hope this will help you

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello ,
try this to get 3 characters after abc

Dim FStr As String
        FStr = txtFind.Text.Substring(Val(txtUsername.Text.IndexOf("abc")), 6).ToString
        txt2.Text = FStr.Substring(3, 3).ToString

txtfind is a textbox having text in which i want to find 3 characters after abc , and txt2 is a textbox which will show the next 3 characters after abc in string.
Hope this will helps you .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well it is nice that your prob is solved , but i think the way you code is not good , it is better to use modules for connection , insert delete, search , update , because it makes your prog easy to debug and easy to understand .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well first remove your ( in your query, then how you want to authenticate the userform , ?? , what i understand is that you want to check the user name and password and the user type then load the form am i right ? so i think if you have two tables or more then two tables there is no need to use dataset , because you can perform same function with a single query , which is easy and fast .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes you can easily do that , you have top use for loop to save your data ,

dim i as integer
for id = 0 to datagrid.rows.count-1
'here put your update command , and value of cells you can by like this
cellvalue = datagrid.item(0,i).value.tostring()'and you can use val(datagrid.item(0,i).value.tostring()) for integer value .
next

make some efforts , if you have any prob , then we are here to solve it :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

if you want to make your form top most then use this

Me.TopMost = True

this will will make your form topmost .

Regards