Wednesday, 10 April 2013

Connect VB 6.0 with Oracle and SQL Server

Database is the heart of any business application. When we make any software then most of the  things floats near of database. As we know oracle is the most popular database in the world connecting oracle to your VB application is very simple simple. take a look on following and please don't tell me thanks..

  • Import a class reference for Project > References
  • Add Microsoft ActiveX Data Objecs 2.8 Library from references
  • Make an object of ADODB.Connection
  • Open DB Connection Consider the connection string
  • Rest of the things are same as you do with access database

Dim con As New ADODB.Connection
    con.Open "Provider=MSDAORA.1;User id=scott;password='tiger';Persist Security Info=False"
    con.Execute "insert into vb values(110,'niraj','lanka')"
    MsgBox "Saved"

SQL Server

Table Name Stu(Roll number,Name varchar2(20),City varchar2(20)), Import Microsoft Active Data Objects 2.0 from Project>References

Save Button Code

 con.Open "Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=bsw"
    con.Execute "insert into stu values(" & Text1.Text & ",'" & Text2.Text & "','" & Text3.Text & "')"