M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
you can use this code at the click event of the listbox

button1.enable= true
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 have no idea how to deal with ms access , but here is a code to insert image in mssql , may be this will give you any idea .

'use this code where you are assigning the values in you command
SqlParameter("@picture", SqlDbType.Image)).Value = arrimage)
   Dim myFile As String = picture
            If picture.ToString.Length <= 1 Then
                Me.myCmd.Parameters.Add("@Picture", SqlDbType.Image).Value = Convert.DBNull
            Else
                Dim myStream As FileStream = New FileStream(myFile, FileMode.Open)
                Dim myImageBuffer() As Byte = New Byte(myStream.Length) {}
                myStream.Read(myImageBuffer, 0, myStream.Length)

                Me.myCmd.Parameters.Add("@Picture", SqlDbType.Image).Value = myImageBuffer
                myStream.Close()
            End If
'and this code is for binding picture box with you sql db
dim con as new sqlconnection("string")
con.open()
dim da as new sqldataadapter("select mypic from table1",con)
dim dt as datatable
da.fill(dt)
picturebox1.databinding.add("image",dt,"mypic",true)
'this code will show your saved pic from mssql to your picture box ,

i know this is not what you are looking for , but this will give you an idea to solve your prob:) .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can do this by using query , can you please tell me about table and fields and on which fields you want to set you record selection criteria .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
if you want to bind combobox then try this

dim con as new sqlconnection("string")
con.open()
dim da as new sqldataadapter("your sql query",con)
dim dt as datatable
da.fill(dt)
'now here you can bind your combobox
combobox.databinding.add("selectedvalue",dt,"your database field name",true)
'combobox.databinding.add("selectedvalue",dt,"CityID",true)--like this

If this code solve your prob then please mark your thread solved :)
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

if you want to update records of images in single table then use loop and if you want to update records of images in multiple tables then it is better to use stored procedures or if you dont know about stored procedure then use multiple update statements to update your records.(please always provide enough description of you prob so that any one can help you.)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i dont know which fields you are taking in grid , lets consider if there is a table name student , having ids , stuid , stuname , stufathername ,stuphonno, now you are showing stuname , stufathername,stuphone in grid and want to do same as you mentioned above then you can write this code for selection.

dim myCmd as string 
myCmd = "select * from persons where stuname='"datagridview1.item("StuName",datagridview1.currentrow.index).value.tostring &"' and stufathername= '"& datagridview1.item("stufathername",datagridview1.currentrow.index).value.tostring&"' and stuphoneno='"&val(datagridview1.item("stuphone",datagridview1.currentrow.index).value.tostring &"'"

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

skp03 hello !
i have an idea , may be this will help you , why not you use clipboard . like this

'place a timer on application1 then place this code on every tick event 
 TextBox1.Text = My.Computer.Clipboard.GetText.ToString
'the code which is copy by the user will auto paste in textbox1 .

i know this is not what you are looking for . but this is what i can do for you right now :),may be this will give you any idea.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
how can this code update database :P you are using select statement instead of update :)

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!
i am working on a Asp.net project using C#, now i want to connect mssql server 2008 using JS or AJAX , i am very new with JS so i have no idea where to start .can anyone help me in this .

Regards

M.Waqas Aslam

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

hello !
please check this link may be it will solve your prob :) http://p2p.wrox.com/sql-language/12823-convert-null-string-concatenation.html

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

skp03 , can you please post some of your code or snap shoots of your forms so that i can better ans you . and if you are working in C# then it is better to post this question in C# forum so that someone can better answer your prob.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

Please explain your question .this is not the right way .:-|

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

check this , may be it helps you

dim myCon as new sqlconnection("your connection string")
dim cmd as new sqlcommand
myCon.open()
cmd.connection=myCon
cmd.commandtext="insert into tablename (field1,field2,field3) values (@field1,@field2,@field3)"
cmd.parameter.add("@field1",______).value = txtvalue1.text 'in place of ___ write datatype of your field in your db.
cmd.parameter.add("@field2",______).value = txtvalue2.text
cmd.parameter.add("@field3",______).value = txtvalue3.text'if you have datatype of your field in your db is int , decimal , bigint, etc then use val(txtvalue.text)
cmd.executenonquery()
myCon.close

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

nice ans hericles :)

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello ! you can do it like this

'first import system.data.sqlclient then
dim myCon as new sqlconnection("your connection string")
dim cmd as new sqlcommand
myCon.open()
cmd.connection=myCon
cmd.commandtext="insert into tablename (field1,field2,field3) values (@field1,@field2,@field3)"
cmd.parameter.add("@field1",______).value = txtvalue1.text 'in place of ___ write datatype of your field in your db.
cmd.parameter.add("@field2",______).value = txtvalue2.text
cmd.parameter.add("@field3",______).value = txtvalue3.text'if you have datatype of your field in your db is int , decimal , bigint, etc then use val(txtvalue.text)
cmd.executenonquery()
myCon.close

this will insert your data in your table . well i write this code here , so may be there are some spelling mistakes , check them by your own self .
If your prob is solved please mark this thread solved .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

in above code we use selected value from the cell of the grid to get all the records of that selected value ,now what is your question please rephrase it .so that i can help you in better and effective way

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

you can set your column readonly property true .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

right click on your project in your solution window , then select ADD ---> Existing Item--->Browse and select your report then press ok . your report will include in your project ,or in order to add new report item then right click on your project in your solution window , then select Add Component--->select crystal report item and press Ok

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

first install sql server management studio , then make sure server computer is connect with your computer , then give that server name like server/sqlexpress , then connect it ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try some other reporting tools , like telerik is one of the best reporting tool now a days ,and you can get full support from here www.telerik.com

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes , because for receipts we use reports , you can use any reporting tool , this will error free , fast and handsome approach .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

your given proj is not working at my end and it gives an error when i run it .you should use break points in your code to solve this type of issues .please in order to get help , post your code or again give new link of working project

regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

Check this Out , May be this will help you :)

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try this code

'use this code on the keydown event of the listbox
If e.KeyData = Keys.Down Then
            ListBox1.SelectedItem = ListBox1.Items(0)
        End If
        If e.KeyData = Keys.Up Then
            ListBox1.SelectedItem = ListBox1.Items(0)
        End If

Hope this helps you

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes it is possible , but can you tell me what you want to print ,every time before printing you want to change amount , and name ,which is not a good approach. as you said that you want to print a payment receipt you can do like this

' Make a new Form, add the following controls

    'Button - btnPrint
    'PrintDocument - prnDoc
    'TextBox - txtNotes

    Dim StringToPrint As String

    'This variable will hold the text to be printed and is assigned in the button press event before the printing is called.

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

        StringToPrint = txtNotes.Text
        prnDoc.Print()

    End Sub

    'Actual printing code is done by overiding the printpage method of the PrintDocument object. This function will have codes to print the content of the textbox without breaking and spreading out of the page.

    Private Sub prnDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prnDoc.PrintPage

        Dim numChars As Integer

        Dim numLines As Integer

        Dim stringForPage As String

        Dim strFormat As New StringFormat()

        Dim PrintFont As Font

        PrintFont = txtNotes.Font

        Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)

        Dim sizeMeasure As New SizeF(e.MarginBounds.Width, e.MarginBounds.Height - PrintFont.GetHeight(e.Graphics))

        strFormat.Trimming = StringTrimming.Word

        e.Graphics.MeasureString(StringToPrint, PrintFont, sizeMeasure, strFormat, numChars, numLines)

        stringForPage = StringToPrint.Substring(0, numChars)

        e.Graphics.DrawString(stringForPage, PrintFont, Brushes.Black, rectDraw, strFormat)

        If numChars < StringToPrint.Length Then

            StringToPrint = StringToPrint.Substring(numChars)

            e.HasMorePages = True

        Else

            e.HasMorePages = False

        End If

    End Sub

hope this will helps you :)

Regards

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

use this code to save pic

'use this code instead of this code (        cmd.Parameters.Add(New SqlParameter("@picture", SqlDbType.Image)).Value = arrimage)
   Dim myFile As String = picture
            If picture.ToString.Length <= 1 Then
                Me.myCmd.Parameters.Add("@Picture", SqlDbType.Image).Value = Convert.DBNull
            Else
                Dim myStream As FileStream = New FileStream(myFile, FileMode.Open)
                Dim myImageBuffer() As Byte = New Byte(myStream.Length) {}
                myStream.Read(myImageBuffer, 0, myStream.Length)

                Me.myCmd.Parameters.Add("@Picture", SqlDbType.Image).Value = myImageBuffer
                myStream.Close()
            End If

regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

See if this helps.
New.Project, 3.Buttons, 3.Panels(view attached image)

Public Class Form1
    Private pnTemp As Panel, iSelPanel As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        pnTemp = Panel1 '// pnTemp, just easier to work w/. :)
        If pnTemp.Height = 0 Then expandPanel(pnTemp) Else collapsePanel(pnTemp)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        pnTemp = Panel2
        If pnTemp.Height = 0 Then expandPanel(pnTemp) Else collapsePanel(pnTemp)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        pnTemp = Panel3
        If pnTemp.Height = 0 Then expandPanel(pnTemp) Else collapsePanel(pnTemp)
    End Sub

#Region "-----===-----===-----===-----===-----===  ===-----===-----===-----===-----===-----"
    Private Sub collapsePanel(ByVal selPanel As Panel)
        With selPanel.Name
            iSelPanel = CInt(.Substring(.Length - 1)) '// get # at end of Panel.Name.
        End With
        For i As Integer = 0 To selPanel.Height '// loop from 0 to panel.height
            selPanel.Height -= 1 '// ...and reduce height.
            For Each ctl In New Control() {Button1, Panel1, Button2, Panel2, Button3, Panel3} '// loop thru all btns and panels.
                If CInt(ctl.Name.Substring(ctl.Name.Length - 1)) > iSelPanel Then '// check if # at end of btn/panel is greater than the selectedPanel.
                    ctl.Top -= 1 '// move btn/panel up.
                End If
            Next
        Next
    End Sub
    Private Sub expandPanel(ByVal selPanel As Panel, Optional ByVal iPanelHeight As Integer = 125)
        With selPanel.Name
            iSelPanel = CInt(.Substring(.Length - 1))
        End With
        For i As Integer = 0 To iPanelHeight
            selPanel.Height += 1
            For Each ctl In New Control() {Button1, Panel1, Button2, Panel2, Button3, Panel3}
                If CInt(ctl.Name.Substring(ctl.Name.Length - 1)) > …
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

what :o , i tested it and then i post this code here , i just again use above mentioned code and if work fine for me , ok here is a sample program which i code for you , hope this time it works for you :)

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

hello
Use this code , hope this will solve your prob

dim mycon as new sqlconnect("connection string")
mycon.open()
dim da as new sqldataadapter("ur selection query",mycon)
dim dt as datatable 
da.fill(dt)
'take binding source 
bindingsource.datasource = dt
datagride.datasource = bindingsource
'now here you can bind your controls 
txt1.databinding.add("text",bindingsource,"field",false)
combobox.databinding.add("SelectedValue",bindingsource,"field",true)

If your prob is solved then please mark this thread solved and vote me up :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try this may be this will help you

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

thanks bro , thank you so much :)

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

thanks all of you :) and sorry for my late reply .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

no one answered :(

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

no one replied , :(

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
array in vb.net is defined like this

dim array(5) as string

hope this will work fine :P

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
use this code for binding

cboOrganization.DataBindings.Add("SelectedValue", ds.Tables(bsTableName2, "OsID",true)

This will work fine :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

POS stands for point of sales , it is basically work like a inventory management system ,it manages your stock transactions , purchase , sales , purchase returns , sales returns, claims , little bit accounts. you can further google it , hope google will provide you a very good information about POS

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
it takes long time to read your all code , but as far as concern about update query ,you can do like this

dim mycon as new sqlconnection("connection string")
dim cmd as new sqlcommand
mycon.open()
cmd.connection= mycon
cmd.commandtext="update tablename set dbcolumnname1=@Column1,dbcolumnname1=@Column2,dbcolumnname1=@Column3 where recID=@RecID"
cmd.parameters.addwithvalue("=@Column1",txt1.text)
cmd.parameters.addwithvalue("=@Column2",txt2.text)
cmd.parameters.addwithvalue("=@Column3",txt3.text)
cmd.parameters.addwithvalue("=@recID",txtRecID.text)

cmd.executenonquery()
mycon.close()

Hope this will helps you
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

right code is

dim Query  as string 
Query = "Select * from T_INCIDENTS1 where 1=1"
'now for example you have 2 textboxes , txt1,txt2 , for you filter
if txt1.text<>"" then
Query = Query & " And Incident_Postcode='" & txt1.Text & "')"
end if
if txt2.text<>"" then
Query = Query & " and Incident_DMA='" & txt2.Text & "') "
end if
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ohh :PPP sorry , i just solve your first issue how to set criteria , sorry again :P

now change your code like this

dim Query  as string 
Query = "Select * from T_INCIDENTS1 where 1=1"
'now for example you have 2 textboxes , txt1,txt2 , for you filter
if txt1.text<>"" then
Query = Query & " And Incident_Postcode='" & txt1.Text & "')"
end if
if txt2.text<>"" then
Query = Query & " and Incident_DMA='" & txt2.Text & "') "
end if

Hope this time it works fin9 :) sorry , again

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
in you db , date format is same as you specified in your windows , so change the date format .secondly users have concern with the interface , time showing on there datetime picker , there you can set the format property custom and set your required format of date

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
you can do like in this way

'place this code at the single click event of the grid
txt1.text = datagrid.item(0,datagrid.currentrow.index+1).value.tostring

hope this will solve your prob :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !

you are adding txtPostcode.text and txtDMA.text in your Query , this totally wrong . you are using totally wrong logic for this query , can you please tell me what you want to get from this query , well you can do like this

dim Query  as string 
Query = "Select * from T_INCIDENTS1 where 1=1"
'now for example you have 2 textboxes , txt1,txt2 , for you filter
if txt1.text<>"" then
Query = Query & " And IFF (txtPostcode.text is notNull) then Incident_Postcode='" & txt1.Text & "')"
end if
if txt2.text<>"" then
Query = Query & " and iff (txtDMA.text is notNull) then Incident_DMA='" & txt2.Text & "') "
end if

Hope this will help you

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok :) now you can do like this

dim Query  as string 
Query = "Select * from T_INCIDENTS1 where 1=1"
'now for example you have 2 textboxes , txt1,txt2 , for you filter
if txt1.text<>"" then
Query = Query & " And IFF (txtPostcode.text is notNull) then Incident_Postcode='" & txt1.Text & "')"
end if
if txt2.text<>"" then
Query = Query & " and iff (txtDMA.text is notNull) then Incident_DMA='" & txt2.Text & "') "
end if

Hope this will solve your prob .

Regards