vb.net l notes for my personal use

1. A textbox should accept ONLY NUMBERS.; write the code.
selct the textbox1 > keypress > code:
Private sub textBox_keyPress(...)....
   If char.IsNumber(e.keychar)=false then
                  e.handled=true
   End If
End Sub
mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
2. Most of the time, we retrieve only one record from the database and place the values in textboxes.  theres is no need for datatase for this purpose. the simplest code for this purpose is ::::


qs='select * from staff where id=2345'
cmd=new oledbcomand(qs,con)
con.open()
rdr=cmd.executereader(commandBehavior.closeconnection)
if rdr.read() then
      txtbox1.text=rdr("staffname").tostring
      txtbox2.text=rdr("desgn").tostring
end if
con.close()

mmmmmmmmmmmmmmmmmmmmm

code for inserting a record into database:
qs='insert into emp(name) vlaus('ram')"
cmd=new oledbcommand(qs,con)
try
      con.open()
      cmd.enq()
      msgbox("done")
catch ex as exception
       msgbox("error")
finally
       con.close()
end try
=================================
datagrid.aspx.vb
sub page_load....
if not page.ispostback then
    dataBind1()
end if
end sub

sub databind1()
dim da as new odda(cmd)
dim ds as n ew dataset
da.fill(ds)
dg.datasource=ds
dg.databind()
end sub
==========================

all about context menu.
  • it is a tool in toolbox
  • it can be mapped to any label
  • when user rightclick on the label, context menu appears
  • how to map a context menu?
  • drag a context menu and fill the properties
  • drag a lable and set its property>>>>
  • lable1.contextmenu=contextmenu1
=================================
all about track bar
|||||||||||||||||||||U|||||||||||||||||
instead of typing the age inside a textbox, you can slide the slider. and age will be automatically placed in the text box.
Take the trackbar and set its properties like this:
min=0, max=100,intitalvalue=0,smallchange=5,largechange=20,
tickfrquency=10

write code in the scroll event:
textbox1.text=trackbar1.value
====================================
c#code to findout how many records are there in a table:
int getCount()
{
int count;
OdbcConnection con=new OdbcConnection("aaa");
OdbcCommand cmd=new OdbcCommand("bbb");
con.open();
count=(int) cmd.ExecauteScalar();
con.close();
return count;
}
what is aaa? server=(local); database=mydatabase; uids=bs;pwd=sk;
what is bbb? "select count(*) from staff",con

==============================
vb code to find out the number of records in a table:
Private Sub getCout as Int32
Dim con as new odbcconnecation*("aaa")
dim cmd as new odbccommand("bbb")
con.open()
dim count as Int32
count=Inte32.Parse(cmd.executescalar())
con.close()
return count
end sub

what is aaa? server=(local); database=mydatabase; uids=bs;pwd=sk;




what is bbb? "select count(*) from staff",con



=================================
difference between public,priage,friend
public=anybody can call him.
private=anybody from his home ( i.e.class) can call him
friend = any from his village (i.e. project) can call him.
========================================
where to use "nothing'
textbox1.text=Nothing
=====================================




 
Thank you spending your time here.
If possible you; can leave some comments or suggestions.
Thanks a lot once again.
Google Search
Disclaimer and Copy Right