Imports System.Data.
OleDb
Imports System.Data
Partial Class Default1
Inherits System.Web.UI.Page
Protected Sub DetailsView1_PageIndexChanging(sender As Object, e As DetailsViewPageEventArgs) Handles
DetailsView1.PageIndexChanging
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As OleDb.OleDbConnection
Dim mydb, mystr As String
mystr = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("mydb1.accdb"))
connection = New OleDb.OleDbConnection(mystr)
connection.Open()
mydb = "INSERT INTO [Name] ([emailid], [password]) VALUES ('zasdasd', 'zewe')"
Dim run = New OleDb.OleDbCommand
Try
run = New OleDbCommand(mydb, connection)
run.ExecuteNonQuery()
MsgBox("connection opened")
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub
End Class
-=----------DeleteCommand="DELETE FROM [Name] WHERE (([emailid] = ?) OR ([emailid] IS NULL AND ? IS NULL))"
InsertCommand="INSERT INTO [Name] ([emailid], [password]) VALUES (?, ?)" ProviderName="<%$
ConnectionStrings:ConnectionString2.ProviderName %>"
SelectCommand="SELECT [emailid], [password] FROM [Name]" UpdateCommand="UPDATE [Name] SET
[password] = ? WHERE (([emailid] = ?) OR ([emailid] IS NULL AND ? IS NULL))">
SELECT Name.emailid, Name.password FROM Name WHERE (((Name.emailid)="prag") AND
((Name.password)="shah"));
SQL
Dim myconnection As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=|
DataDirectory|\Database1.mdf;Integrated Security=True;Connect Timeout=30")
myconnection.Open()
Label1.Text = myconnection.State
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim myconnection As New SqlConnection("Data
Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True;Connect Timeout=30")
' myconnection.Open()
Label1.Text = myconnection.State
Dim myCommand As New SqlCommand()
myCommand.Connection = myconnection
myCommand.CommandText = "SELECT * FROM [Table] where password='shaw'"
Dim reader As SqlDataReader
Try
myconnection.Open()
reader = myCommand.ExecuteReader()
reader.Read()
Label1.Text = reader("emailid").ToString()
'txtID.Text = reader("au_id").ToString()
reader.Close()
myconnection.Close()
Catch ex As Exception
Label1.Text=ex.Message
End Try
End Sub
End Class
===========
myCommand.CommandText = "SELECT count(*) FROM [Table] where password='shaw'"
Dim reader As SqlDataReader
Try
myconnection.Open()
Dim count As Integer = CType(myCommand.ExecuteScalar(), Integer)
MsgBox(count)
Dim myCommand As New SqlCommand()
Dim vcounter As Integer
myCommand.Connection = myconnection
'myCommand.CommandText = "SELECT count(*) FROM [Table] where emailid = '" &
TextBox1.Text & "'"
myCommand.CommandText = "SELECT count(*) FROM [Table] where emailid = '" &
TextBox1.Text & "' and password ='" & TextBox2.Text & "'"