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

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 !
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

thanks guys for your valuable time and comments , :)

God bless you all

Regards

dantinkakkar commented: Repo4Following Forum Ethics :) +4
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok try this

'place this code at the click event of your grid , but please make sure that the selection property is set to the full row select.
txtid.text = datagridview.item("columnname/Index",datagridview.currentrow.index).value.tostring() 'if you give the column name then use "" if you want to give index then dont use them.

If this code solve your prob . please mark your thread solved and vote me up :)

Regards

networkmancer commented: thanks +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok well use this , may be this will solve your prob

dim i as integer
dim a as string 
for i = 0 to datagridview1.rows.count-1 
a = datagridview1.item(2,i).value.tostring()
 if a =   Now.Date.ToString() then 
 'now here put your code you want to execute
endif
next

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think in your booking application add sms and email modules to give alerts to the customers .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
try this code

dim i as integer
for i = 0 to datagridview1.rows.count-1 
 if datagridview1.item(2,i).value.tostring =   Now.Date.ToString() then 
 'now here put your code you want to execute
endif
next

Hope this will helps you if yes then please mark your thread solved and vote me up :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
please use this code this will solve your prob :)

Dim str As String
        Dim strArr() As String
        Dim count As Integer
        str = txtUsername.Text ' txtbox having txt you wana split.
        strArr = str.Split("_")
        For count = 0 To strArr.Length - 1
            If txt1.Text = "" Then
                txt1.Text = strArr(count).ToString

            Else
                If txt2.Text = "" Then
                    txt2.Text = strArr(count).ToString
                Else
                    If txt3.Text = "" Then
                        txt3.Text = strArr(count).ToString
                    End If
                End If
            End If

        Next

if your prob is solved then pleas mark this thread solved and also dont forget to add reputation .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
Yes,there is a way.

Set KeyPreview property of your Form to True.
And use this code for your Form_KeyDown event:

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Return Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

hope this helps you.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you can use this code at the double click event of the listbox whose value you want to show.

Form2.ListBox1.Items.Add(ListBox1.SelectedItem.ToString)

hope this code helps you , if yes then please vote me up :)

Regards

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

try this code :)

If ListBox1.Items.Count = 0 Then

        Else

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

then please check you id and password again at www.gmail.com. because there is nothing wrong with that code .

vivekanandaan commented: spontaneous help ..... +2
M.Waqas Aslam 67 Posting Pro in Training Featured Poster
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok but you want to show just surname middlename and firstname in your report , if yes , then please group on surname middlename and firstname .then in your report only one record will show . and if you are using query and generating your report programmetically then use group by clause in your query .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you want to show msgbox with the selected data of combo by clicking on the button ? if this is what you want then you can do like this

msgbox(combobox.text)

or if this is not what you want please rephrase you question:)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you can do this in this way also .

dim mycon as new sqlconnection("connectionstring")
mycon.open()
dim da as new sqldataadapter("select * from table1",mycon)
dim dt as datatable
da.fill(dt)
combobox1.datasource = dt
combobox.displaymember = "field name you want to show "
combobox.valuemember  ="field name you want to get as a value "
mycon.close

Hope this will helps you
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
Please check the attached solution , it will ban single user for 10 mints ,

ryklon commented: Helped me out. +1
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
if you are using db with this application then make a table for example name tblLogingFail .now when ever you want to ban a user then insert data in that table fields name recID,UserID,Logindate , now after this set condition that if logintime difference is less then 10 min then dont allow user and if difference is more then 10 mint allow him to login.

Regards

ryklon commented: Thanks for gaving me hints. +1
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello LearnVBnet!
i read this thread more then 5 times , but i still not able to understand what is your question "How to NoT In Paylist LvList where InvNomer have add to dgv Payment
Not Display InvNomer in LvList Paylist where InvNomer in Dgv Payment." this the description of your prob ,please provide some explanation so that any one can help you in a good way ,
well as i understand that you have a list box and a grid , you want to remove all the items from the list view those are present in a grid view ,if this is your prob then try to use this code , hope this will solve your prob .

Dim i As Integer
        Dim x As Integer
        Dim find As Boolean
        Dim rec As New ArrayList
        For i = 0 To ListBox1.Items.Count - 1
            find = False
            A = ListBox1.Items(i).ToString
            For x = 0 To DataGridView1.Rows.Count - 1
                B = DataGridView1.Item(0, x).Value.ToString
                If A = B Then
                    find = True
                    Exit For
                End If
            Next
            If find = True Then
                rec.Add((ListBox1.Items(i)))
            End If
        Next
        Dim ab As Integer
        For ab = 0 To rec.Count - 1
            ListBox1.Items.Remove(rec.Item(ab))
        Next

and if this is not the answer of your prob then please rephrase your question.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

Hello !
i watched this given video . it is very simple i write this code right here so there may be some spelling mistake in it. check this out
dgvTableList---is a grid which will show tables of selected database
dgvAllRecords---it will show all records of the selected table

'first import these 
'--------------------------------------------------------------------
Imports System.Data.OleDb
import system.data.sqlclient

'--------------------------------------------------------------------
'use this code at the connect button .

if combobox.text = "System.Data.OleDb" then 

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&txtserver.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
      Dim cmd As OleDbCommand = New OleDbCommand("Select Name from MSysObjects", con)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        dgvTableList.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
end if
if combobox.text = "system.data.sqlclient" then 

Dim con as new sqlconnection("Data Source="&txtserver.text&";Initial Catalog="&txtdb.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
con.open()
dim da as sqldataadpter("Select name from sys.tables",con)
dim dt as datatable
da.fill(dt)
dgvTableList.datasource = dt
con.close()
end if

'place this code on the double click event of your dgvTableList

if combobox.text = "System.Data.OleDb" then 

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&txtserver.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
      Dim cmd As OleDbCommand = New OleDbCommand("Select * from " & dgvTableList.item(0,dgvTableList.currentrow.index).value.tostring , con)'u can use the name of you column in place of 0 (column index)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        dgvAllRecords.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
end if
if combobox.text = "system.data.sqlclient" then 

Dim con as new sqlconnection("Data Source="&txtserver.text&";Initial Catalog="&txtdb.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
con.open()
dim da as sqldataadpter("Select * from " & dgvTableList.item(0,dgvTableList.currentrow.index).value.tostring ,con)'u can use the name of …
GAiXz commented: Thanks to this ^_^ +1
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
check this code this will show some records in datagrid and some of them in textboxes as you mentioned in your snap shoot.

dim con as new sqlconnection("connection string")
dim da as new sqldataadapter("select * from table or your query",con)
dim dt as datatable 
da.fill(dt)
'take a bindingsource 
bindingsource1.datasource = dt
'and if you want to see all the records one by then then you can use binding navigator for it like in this way
'--------------------------------------------
bindingNavigator.datasource = bindingsource1
'--------------------------------------------
datagridview1.datasource= bindingsource1
with datagridview1
 .column(0).visible = false ' here you can give index of the field you dont want to show in grid and also you can give the column name in place of 0 like this column("recordid").visible= false
.
.
.
.
end with
'now here bind your textboxes 
txt1.databinding.add("text",bindingsource1,"fieldname of db",false)'now here you bind your textboxes ,if you want to bind combobox then write selectedvalue in place of text and change false to true.
'bind all you textboxes like this .

Hope this will solve your prob , or give you some idea.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i cant get your point , i think you want to select all records from persons table of selected person id in grid , if i am wrong then please correct me , well for simple select case you can do like this

dim myCmd as string 
myCmd = "select * from persons where personID=" val(datagridview1.item("Personid",datagridview1.currentrow.index).value.tostring)'you can use index of your column in place of "personid".

this will select all the records from the table persons of selected personid

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you can do like this

'enable timer by using this code
timer1.enable= true
'now give interval , 1000 = 1 sec you want to perform action after 60 sec so
timer1.interval=60000
'now code this on the timer tick event 
My.Computer.Audio.Play("ur sound file path")

hope this will solve you prob
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you can perform your required function like this

dim myCon as new sqlconnection("connection string")
dim cmd as new sqlcommand
dim i as integer
myCon.open()
for i = 0 to datagrid1.rows.count -1 
   cmd.commandtext = "delete from table1 where RecID=@RecID"
   cmd.connection = myCon
   cmd.parameter.addwithvalue("@RecID",datagrid1.item(0,i).value)
   cmd.executenonquery()
next
myCon.close

i write this code here in posting thread textbox so may be there is some spelling mistake , but i hope even if this will not solve your prob but this will give you a idea to solve your prob.(sorry for bad english)

Regards

M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

Ok Let me rephrase it

I have 2 forms....
When I click on the button of first form it redirects me to the second form which has a datagrid.
When I select any value from the datagrid and click on a button avaialble in the same form the value that I get from the datgrid shoud be displayed on the first form again

But the issue that I am facing is....
When I click on the button of the second form it open the new first form and the earlier values that were there eneterd manually on the first form goes away....

u should check ur load event of the first form , use this code on the button of the 2nd form.

form1.textbox1.text = datagridview1.item(columnindex,datagridview1.currentrow.index).value.tostring
form1.show()
me.close()

this will work fine , if u face same prob then please show ur code here so that we can find any mistake or u can check again , there should be some logical mistake from ur side ,
Hope this will helps u

Regards

M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
u have to import ur data from excel to access then u can put all ur data in dataset for populating ur grid then save it in MSSQL ,
but first u have to import ur excel data in access

Regards
M.Waqas Aslam

Reverend Jim commented: Not details and introduces an unnecessary complication (Access). -2
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes u can do this , use selection formula , for this .
Regards
M.Waqas Aslam