Feeds:
Posts
Comments

Archive for July, 2006

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
Dim cmd As OleDb.OleDbCommand
Dim icount As Integer
Dim conn As OleDb.OleDbConnection
Try
 conn = GetConnection()
 conn.Open()
        str = “insert into address values(” & CInt(TextBox1.Text) & “,'” & TextBox2.Text & “‘,'” & TextBox3.Text & “‘,'” & TextBox4.Text & “‘,'” & TextBox5.Text & “‘)”
        ‘string stores the command and CInt is used to convert number to string
        cmd = New OleDb.OleDbCommand(str, conn)
        icount = cmd.ExecuteNonQuery
        MessageBox.Show(“No of row inserted:” & icount)
Catch ex As Exception
        MsgBox(“Exception from insert:” & ex.ToString())
End Try
conn.Close()
End Sub

Public Function GetConnection() As OleDb.OleDbConnection
‘return a new connection to the database
Return New OleDb.OleDbConnection(“Provider=Microsoft.Jet.OleDb.4.0;data source=C:test.mdb;”)
End Function

Read Full Post »

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As OleDb.OleDbConnection = GetConnection()
Dim ds As New DataSet
Dim sql As String = “select * from address”
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql, conn)
da.Fill(ds, “address”)
DataGrid1.DataSource = ds.Tables(“address”)
End Sub

Public Function GetConnection() As OleDb.OleDbConnection
‘return a new connection to the database
Return New OleDb.OleDbConnection(“Provider=Microsoft.Jet.OleDb.4.0;data source=C:test.mdb;”)
End Function

Read Full Post »

read text file in vb.net

Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
Dim LineIn As String
oRead = oFile.OpenText(“C:sample.txt”)
While oRead.Peek -1
LineIn &= oRead.ReadLine()

End While
RichTextBox1.Text = LineIn
oRead.Close()

Read Full Post »

read a text file in vb.net

Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
Dim LineIn As String
oRead = oFile.OpenText(“C:sample.txt”)
While oRead.Peek <> -1
 LineIn &= oRead.ReadLine()
End While
RichTextBox1.Text = LineIn
oRead.Close()

Read Full Post »

write text file in vb.net

Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText(“C:sample.txt”)
oWrite.WriteLine(“Write a line to the file”)
oWrite.WriteLine()
oWrite.Close()

Read Full Post »

Sometime wee need to print page number, total no of pages, page location ect. in our printing page. There are commands to write such important things.
 
CODE DESCRIPTION PREVIEW
&w Window Title Print window title &w
&u Page Address http://www.yahoo.com
&d Date in Short Format 7/17/2006
&D Date in Long format Monday. July 17, 2006
&t time 1:14:03 PM
&T Time in 24 hour format 23:14:03 PM
&p Current Page number Page number &p
&P Total Number of Pages Total no of pages &P
     
Referance: http://www.febooti.com/products/iezoom/ print-web/print-web-page-windows-title.html

Read Full Post »

write file in vb.net

Dim fs As New FileStream (“test.txt”, FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
Dim length As Integer
s.BaseStream.Seek(0, SeekOrigin.End)
s.WriteLine(“This example of using file handling concepts in VB .NET.”)
s.WriteLine(“This concept is interesting.”)
s.Close()

Read Full Post »

Older Posts »