Vb6 questions

Closed
Nilesh - Feb 26, 2009 at 11:14 PM
Cung Sen Pao Posts 3 Registration date Thursday February 26, 2009 Status Member Last seen February 26, 2009 - Feb 26, 2009 at 11:29 PM
Hello,
I want to ask you what i can link my vb page to data base?i want brief answer and coding for its.

3 replies

Cung Sen Pao Posts 3 Registration date Thursday February 26, 2009 Status Member Last seen February 26, 2009
Feb 26, 2009 at 11:25 PM
I can't say more for VB6 but I make VB.NET 08 for you. Just a simple code which show string connection to database. Easy to understand.
Public Class Form1

Private Sub BtnConnStr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnConnStr.Click
Dim Conn As OdbcConnection
Dim ConnStr As String = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & My.Application.Info.DirectoryPath & "\Mhs.mdb"

Try
Conn = New OdbcConnection(ConnStr)
Conn.Open()
MsgBox("Koneksi ke : " & Conn.DataSource & vbCrLf & _
"Database : " & Conn.Database & vbCrLf & _
"Driver : " & Conn.Driver.ToString & vbCrLf & _
"Connection String : " & Conn.ConnectionString, MsgBoxStyle.Information, "Connected")
Conn.Close()
Conn = Nothing
Catch ex As Exception
MsgBox("ODBC Error : " & ex.Message)
End Try
End Sub

Private Sub BtnConnStrUsing_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnConnStrUsing.Click
Dim ConnStr As String = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & My.Application.Info.DirectoryPath & "\Mhs.mdb"

Try
Using Conn = New OdbcConnection(ConnStr)
Conn.Open()
MsgBox("Koneksi ke : " & Conn.DataSource & vbCrLf & _
"Database : " & Conn.Database & vbCrLf & _
"Driver : " & Conn.Driver.ToString & vbCrLf & _
"Connection String : " & Conn.ConnectionString, MsgBoxStyle.Information, "Connected dengan Using")
End Using
Catch ex As Exception
MsgBox("ODBC Error : " & ex.Message)
End Try
End Sub
End Class
0
Cung Sen Pao Posts 3 Registration date Thursday February 26, 2009 Status Member Last seen February 26, 2009
Feb 26, 2009 at 11:27 PM
Hi, I'm new here and late for introduction but I'm in hurry. Please view my problem and give me your idea. I'm really stuck in there.
0
Cung Sen Pao Posts 3 Registration date Thursday February 26, 2009 Status Member Last seen February 26, 2009
Feb 26, 2009 at 11:29 PM
My english is not well.I'm Indonesian
0