M.Waqas Aslam 67 Posting Pro in Training Featured Poster

I simply take this example from w3school and made some changes hope this will help you

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("#Button1").click(function(){
      $("#div1").fadeOut();
        $("#div2").fadeIn();
    });
    $("#Button2").click(function () {
        $("#div2").fadeOut();
        $("#div3").fadeIn();
    });
    $("#Button3").click(function () {
        $("#div3").fadeOut();
    });
});
</script>
</head>

<body>
<div id="div1" style="height:80px;background-color:red;"><input id="Button1" type="button" value="button" /></div><br>
<div id="div2" style="height:80px;display:none;background-color:green;">  <input id="Button2" type="button" value="button" /></div><br>
<div id="div3" style="height:80px;display:none;background-color:blue;">  <input id="Button3" type="button" value="button" /></div>

</body>
</html>
mattyd commented: Thank you +7
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

May be when someone delete record ,instead of deleting records code is setting any flag in the table.

to get the clue , you could check the code which is retriving records from the db. there may be any filter criteria.

Regards

Begginnerdev commented: That was the same thought process I had as well. +8
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

Thanks for your time pritaeas. I created two constraints here is the code for others.

ALTER TABLE member_email
ADD CONSTRAINT chk_Email_Cell CHECK(
                (cellNbr is not null and email is null)
                or
                (cellNbr is null and email is not null)
    )


ALTER TABLE member_email
ADD CONSTRAINT chk_Cell_Carrier CHECK(
                (cellNbr is not null and Carrier is not null)
                or
                (cellNbr is null and Carrier is null)

    )

Thread is solved.
Regards

pritaeas commented: Thanks for sharing. +14
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

Read it Click Here

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can decompile the application, hope you find a way . :P

Regards

Begginnerdev commented: Yep! +8
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

use this

 ddl_Course.DisplayField = "course_name";
ddl_Course.ValueField = "course_id";
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you should configure your sql server before .click on start --> microsoft sql server 2005 --> configuration tools --> sql server surface area configuration ---> surface area configuration for services and connections --> select remote connection option from the list on left side. then enable local connections and remote connections.
After doing above process , then again go on start--> microsoft sql server 2005 --> configuration tools--> sql server configuration manager --> sql native client configuration (left side list)--> check tcp/ip service is enable if it is disable then enable it and restart your mssql server.

After do above process , i hope you will able to connect your sql server remotly .

Regards

Reverend Jim commented: Welcome back. +12
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

no one will give you complete code . try to make it by your self. then in case of any issue post your query here. people of daniweb are not here to provide complete solutions.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try this

dim con as new sqlconnection("connection string")
con.open()
dim da as new sqldataadapter("select userId , userName from users",con)
dim dt as new datatable

da.fill(dt)
comboBox.datasource= dt;
with combobox
    .displaymember="userName"
    .valuemember="userId"
end with

con.close()

Hope this will help you

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

dont use this Trim(newQE_Date.ToString("MM-dd-yyyy HH:mm:ss")), just get value and insert it .

Regards

Hazuan Nazri commented: Nice!! +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please check these links , hope you will find something usefull in them
Click Here

in my point of view you have to format part of the string here are some links please check them out

Click Here

Click Here
Click Here

Regards

joshl_1995 commented: Thanks for the help +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

in order to add new row you have to define column in your grid then just add row like this
for example i have to textboxes txtName , txtFatherName and a grid with two columns , name and father name , a button , i want to add new row in my grid by clicking that button. use this code at the click event of the button

datagridview1.rows.add(txtName.text,txtFatherName.text)

this will add row to your grid.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok here is a example , you can search your all emplyees by there names , do something like this first take a form with a grid and a textbox , now use this code at the textbox text change event.

dim con as new sqlconnection("your connection string")
con.open()
dim da as new sqldataadapter("select EmpName from emloyees where empName like '%" & textbox1.text & "%'" ,con)
dim dt as new datatable
da.fill(dt)
datagridview1.datasource = dt
con.close()

it will work fine :P Hope it will help you . if your prob will solved then please mark this thread solved.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

just go to file menu then new project ---> other project types ---> setup and development ---> give name and select path where you want save your setup --->press ok
after that a page will open having two columns , on your left side there will be there options 1-application folder 2-users desktop 3-users program menu ,
first click on application folder then on right side just right click select Add--->files---> browse your bin folder of your project select all files and folder in it and press ok
then click on users desktop option and then again right click on right side then select Create new shorcut ---> a window will open , select application folder and then select file .exe and press ok

then go to Build menu and there will 3rd option Build YourProjectName click it . Done :P
You have created your first setup.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes you can use web browser control in vb.net form and after that you can easily edit the webpage. but for this you have to make your or custom browser.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

just right click on your project , select properties then select compile option then select advance compile option then there will a combobox with value .net 4 Client Profile just select .net framework 4 . you will have crystal report viewer for use :)
if this helped you please vote me up :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes you can join then or use nested select statements ,like this

Customers

custid
custname

Interest

interestid
custid
interestname

now you have to get all the customers who have interest in football , you can do like this .

select c.custid,c.custname ,i.interestname
from customers c
inner join interest i on i.custid = c.custid
where i.interestname = 'football'

and you can do like this also but this is not i recommend for you.

select c.custid,c.custname ,
            (select i.interestname from interest i where i.custid = c.custid and
             i.interestname = 'football') as InterestName
from customers c

the above query is faster then this.
tip: always try to avoid nested select statements in your query as much as possible. nested select statement slowdown your query.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can do somthing like this . add a module and just call this public sub at your form when ever you want to clear your textboxes or other controls .

   Public Sub ClearAllTextBox(ByVal myControl As Object)
            Dim i As Integer
            For i = 0 To myControl.Controls.Count - 1
                If TypeOf myControl.Controls(i) Is TextBox Then
                    myControl.Controls(i).Text = ""
                ElseIf TypeOf myControl.controls(i) Is MaskedTextBox Then
                    myControl.controls(i).text = ""
                ElseIf TypeOf myControl.controls(i) Is ComboBox Then
                    myControl.controls(i).text = ""
                End If
            Next
        End Sub

just call it like this where you need.

    ClearAllTextBox(me) 
    'or if you have many group boxes or panel then then in place of me just write the name of group box or panel like this 
    ClearAllTextBox(groupbox1)

hope this will help you

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try something like this

dim con as new sqlconnection("connection string")
dim cmd as new sqlcommand
con.open()
cmd.connection = con 
cmd.commandtext = "update table1 set col1=@col1,col2=@col2,col3=@col3,col4=@col4 where recid = @recid"
cmd.paramerter.addwithvalues("@col1",txt1.text)
cmd.paramerter.addwithvalues("@col2",txt2.text)
cmd.paramerter.addwithvalues("@col3",txt3.text)
cmd.paramerter.addwithvalues("@col4",txt4.text)
cmd.paramerter.addwithvalues("@recid",txtRecId.text)
cmd.ExecutenonQuery()
con.close()

i typed it here so may be there are some spelling mistakes in it ,hope this will solve your prob :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
i want to develop the keycounter , i mean i want to get the total no. of key pressed by the user in the specific time , i have a code of keylogger , i can use it to get the text in that time period and after that just get its length , but i dont want to use this . here is a code of VB.net which i found so for on msdn

Private Shared keyPressCount As Long = 0
    Private Shared backspacePressed As Long = 0
    Private Shared returnPressed As Long = 0
    Private Shared escPressed As Long = 0


    Private Sub myKeyCounter(ByVal sender As Object, ByVal ex As KeyPressEventArgs)
        Select Case ex.KeyChar
            ' Counts the backspaces.
            Case ControlChars.Back
                backspacePressed = backspacePressed + 1
                ' Counts the ENTER keys.
            Case ControlChars.Lf
                returnPressed = returnPressed + 1
                ' Counts the ESC keys.  
            Case Convert.ToChar(27)
                escPressed = escPressed + 1
                ' Counts all other keys.
            Case Else
                keyPressCount = keyPressCount + 1
        End Select

        textBox1.Text = backspacePressed & " backspaces pressed" & _
            ControlChars.Lf & ControlChars.Cr & escPressed & _
            " escapes pressed" & ControlChars.CrLf & returnPressed & _
            " returns pressed" & ControlChars.CrLf & keyPressCount & _
            " other keys pressed" & ControlChars.CrLf
        ex.Handled = True
    End Sub 'myKeyCounter

and

    Public Sub New()
        InitializeComponent()

        AddHandler TextBox1.KeyPress, AddressOf myKeyCounter
    End Sub 'New

i get this code from this link Click Here. this code working fine but only when my …

zrehman809 commented: is there an application (or an "innocuous" keylogger) that could tally how often I press the keys on my console amid a particular time +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

change this code with this

Checkbox1.Text * TextBox2.Text ' it your code change it 

val(Checkbox1.Text) * val(TextBox2.Text) ' use this code.
alexandra.lopez.94043 commented: If Checkbox1.Checked = True Then welcomemessage = TextBox2.Text & vbTab & Checkbox1.Text & Str(Val(Checkbox1.Text) & Val(TextBox2.Text)) & vbCr totalprice = Str(Val(Checkbox1.Text) & Val(TextBox2.Text)) +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , there is not that much time to read all your code , i have a better suggestion for you , you can just edit all the records in your grid , after that save all your records , it is simple fast and it will reduce your work ,

Regards

prancode commented: can you send me the code to do it? +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well simple use this.

msgbox(txtbox.text)

and if you have so many txtboxes and want to show the data in masg then you can use this.

msgbox("name:" & txtName.text & vbCrlf & "Age:" & txtAge.text)

hopr this will help you.
Regards.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , you have to use the array list , for this purpose ,
here is what i tried at my end first i add a list box and a button on my form , i add 4 items a b c d manually in the list box , then i declare an arraylist and used this code at the load event of my form

       Dim i As Integer
        For i = 0 To ListBox1.Items.Count - 1

            Dim a As String
            a = ListBox1.Items(i).ToString()
            MsgBox(a)
            arr.Add(a)
        Next

this code will insert all the items of the list box in my array list , now i used this code the remove button

 Dim i As Integer
    i = ListBox1.SelectedIndex
    ListBox1.Items.RemoveAt(i)
    arr.RemoveAt(i)

this code will remove items of from the listbox and also from the array list ,

this code is random , and not in a ideal format , may be this approch is acceptable for you , but i hope this code will help you.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

agree wih you jim ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you can do like this, now here is sample you can do same with your close function ,

Public Function Open_DB_Connection(byval formName as string) As String
        Try
            Connection.ConnectionString = "Data Source = LocalHost\;Initial Catalog = Database;Integrated Security  = True"
            Connection.Open()
            Return "Success"
        Catch ex As Exception
            MsgBox("your " & formName & " has Connection Error: " + ex.Message)
            Return "Fail"
            Exit Function
        End Try
    End Function

now you can easily call this function like this .

Open_DB_Con = Open_DB_Connection("your from name")

hope this will solve your prob :)

best Regards

Muhammad Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , you can do this by declaring a global variable , named invoiceno , and then get the value of invoice from the grid and use that value at the new form load event , for example you have two forms , frmchoose , frmshow, and a global variable name invoiceno. now use this code.

'at the double click of your grid
invoiceno = datagrid.item(0,datagrid.currentrow.index).value.tostring()
frmshow.show()

'now assume you have a query through which you are filtrng records , now do like this
sql = "select * from sales where invoiceno="& invoiceno

may be this will solve your prob
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can simply do this like this

'Can only accept future dates(from today to the future, not the past)
if datetimepicker.value.date >= now.date() then
' if true then code here
else
'if false then here
end if

'Can only be AFTER departure date 
if datetimepicker.value.date > departuredate then
'true then code here
else
'false code here
end if 
'can only be in the past and NOT current 
if datetimepicker.value.date< now.date() then
' true coding here
else
'false coding here
end if

if anyone find it wrong , its better to notify me not to press down arrow.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you have to use simple head detail concept or you can call it master detail concept . now here is a sample layout of your master - detail or head- detail tables
head/master table
1- headid PK
2-orderdate
3-orderid-
4-customerid

detail table
1-detailid PK
2-headid FK
3-productid
4-qty
5-rate
6-total

now in your head table you can save the records which are not repeating in your orders , for example , your customer will be one in one order , your order id will be same , and in detail , you have so many products which are ordered by the customer , by using this style you can order more products at the same time. hope this will give you an idea .

Regards

Farhan_B commented: Great :) +3
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please mark this thread solved , as you get the answer. so that others may find it helpful and they saved their time.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please first you should know the difference between dataset and datatable , when ever you are using dataset then please define a table in it , like this

dim ds2 as new dataset
ds2.table("table").clear()
'now after this fill dataset like this 
DataAdapter1.fill(ds2,"table")
'now assign the data source to the grid
DataGridView1.datasource = ds2.table("table")

this will work fine , in single dataset there can be one or more then one tables . so when ever you are using single table then there is no need to use dataset , use datatable .

Best Regards

poolet25 commented: Perfect!!!! +1
M.Waqas Aslam 67 Posting Pro in Training Featured Poster
kingsonprisonic commented: good link... +5
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok , first we have to show values in grid

dim con as new sqlconnection("connectionstring")
con.open()
dim da as new sqldataadapter("select id,name from table",con)
dim dt as new datatable
da.fill(dt)
datagrid.datasource = dt 
con.close

now above code will show records id and name from table table , so now we have to update the records from the grid after making change , do like this

for i = 0 to datagrid.rows.count-1 
dim con as new sqlconnection("connectionstring")
con.open()
dim i as integer
dim cmd as new sqlcommand 
cmd.commandtext = "update table set name='"& datagrid.item(1,i).value.tostring &" where id=" val(datagrid.item(0,i).values.tostring)
cmd.connection = con
cmd.executenonquery() 
con.close
next

this will update field name , note: as i type all this code here , so may be there are some spelling mistakes , please do not copy paste , first understand the code then start writing , without efforts there is no learning ,

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
try this code , hope this will solve your prob.

Sub values()
        Dim con As New SqlConnection("connectionstring")
        con.Open()
        Dim da As New SqlDataAdapter("select name , idno from students", con)
        Dim dt As New DataTable
        da.Fill(dt)
        ComboBox1.DataSource = dt
        ComboBox1.DisplayMember = "name"
        ComboBox1.ValueMember = "idno"
    End Sub
'-----------------
'use this code at the selectedindex change event of your combobox
'-----------------
  TextBox1.Text = ComboBox1.SelectedValue.ToString()

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hmmm , you are right it means nothing to me , but it really make my day sad :(

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

we can not do anything with our life , but people who are managing this site , can do something , as we can not give reputation with out giving any reason , they can make it possible with down vote also .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes farhan , these are variables , you can replace with them with your controls like this

username = @username 
'--------------
username = txtusername.text

i can better help you if you provide some more code :)

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
well today i got two down votes , i dont think that there is any thing wrong with my post , as we know who add reputation to us , can we know the person who is down voting us , and is there any way to balance them , well this thing make me feel very bad , i always tried to help others and to share my knowledge and to learn something new from you experienced people.but this thing is very bad , :( , i spend lots of time when someone post a question to answer him , am i doing all this to get down votes :( ,

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
check this

"UPDATE cg_security_user_right  SET user_id=@user_id, right_id=@right_id ,enable_flag=@enable_flag  WHERE LastName= " & tuser.Text & " right_id = " & tright.Text & " enable_flag = " & CheckBox1.Enabled & ""
'@name they are the variables and you can also replace them with you textboxes or using command parameters to give values.

Reagrds

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you should set your application form prop , show in task bar = false ,then use this code at the closing event of your form

System.Diagnostics.Process.Start("shutdown", "-s -t 00")

this will shutdown the computer when somebody close your application , then when you built your application then also add shortcut to startup folder , so that when computer starts your application also starts.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
you can do like this

dim con as new sqlconnection("connection string")
con.open()
dim da as new sqldataapter("select * from foods where foodtype='"&combo.text&"'",con)
dim dt as new datatable
da.fill(dt)
gridview.datasource = dt
con.close()

use this code at the button click event you will find all the records of the selected type , and if you want to populate your combo also then use this code at the load event of your form

dim con as new sqlconnection("connection string")
con.open()
dim da as new sqldataapter("select foodType from foods",con)
dim dt as new datatable
da.fill(dt)
Combo.datasource = dt
combo.displaymember = "foodType"
con.close()

Regards

thehunk commented: good work +0
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you want that your combo will show values without pressing a button ? , if yes then just call the code at the load event of your form , or you can also use this code at the combo's got focus event , so when you got focus at combo then it will show your records , if i am wrong then please describe your requirement , and prob .

Regards

poolet25 commented: Perfect!!!! +1
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please use this code , if this time you got any prob then next time i will post the example solution , :P

Sub values()
        Dim con As New SqlConnection("Data Source=waqas\sqlexpress2;Initial Catalog=myDB;Integrated Security=SSPI;")
        con.Open()
        Dim da As New SqlDataAdapter("select name , idno from students", con)
        Dim dt As New DataTable
        da.Fill(dt)
        ComboBox1.DataSource = dt
        ComboBox1.DisplayMember = "name"
        ComboBox1.ValueMember = "idno"
    End Sub
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

congratulation ,on your completion of second project :) ,

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

YOUR PK is auto incremented by the database ?

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

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

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

hello !

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

this will solve your prob .

Regards