Monday, July 27, 2009

Connecting database to vb?

Imports System.Data.OleDb


Public Class Form1


Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Fran\Desktop\userpass.mdb;Persi... Security Info=False"


Dim cmd As String = "Select * from Accounts"


Dim adapter As New OleDbDataAdapter(cmd, conn)


Dim Accounts As New DataSet


'adapter.Fill(Accounts)





Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load





End Sub





Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


'If TextBox1.Text = ("Eric") And TextBox2.Text = ("Maclean") Then


MsgBox("hi")


If TextBox1.Text = ("Eric") And TextBox2.Text = ("Maclean") Then


MsgBox("Hey")


Else


MsgBox("Go away")


End If


End Sub


End Class


That's my code, which im trying to connect to a database .


It goes:


If Username = Eric password = Eric


then


Msgbox ("Hey")


msgbox "hi"

Connecting database to vb?
From the looks of it, this is VB.NET with an Access database?





If so, take a look at http://asp101.com/samples/db_simple_aspx...





That contains a basic sample of a database connection method. You'll have to modify it a bit to use Access instead of Sql Server.





http://www.asp101.com and http://www.4guysfromrolla.com both have really good tutorials for VB.NET.


No comments:

Post a Comment