frnds plz ans fast....
I have only one day to my project submission.
Imports System.Data
Imports System.Data.SqlClient
Public Class LoginForm1
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim query As String
Dim sqlq As String
Private Sub DELETETIME()
If con.State = ConnectionState.Open Then con.Close()
con.Open()
query = "DELETE FROM USERLOG WHERE USERID='" & USERNAME & "'"
COMMAND = New SqlCommand(query, con)
COMMAND.ExecuteNonQuery()
End Sub
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim CMD As SqlCommand
If con.State = ConnectionState.Open Then con.Close()
con.Open()
query = "select * from USERLOGIN where USERID='" & txtUsername.Text & "'and UPASSWORD='" & txtPasswd.Text & "'"
da = New SqlDataAdapter(query, con)
ds = New DataSet
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
'valid user
USERNAME = txtUsername.Text
USERTYPE = ds.Tables(0).Rows(0).Item(3)
logintime = Now
DELETETIME()
If con.State = ConnectionState.Open Then con.Close()
con.Open()
'query = "UPDATE USERLOG SET ULOGDATE='" & Today & "',ULOGINTIME='" & Now & "' WHERE USERID='" & USERNAME & "'"
query = "INSERT INTO USERLOG VALUES('" & txtUsername.Text & "','" & Today & "','" & Now.TimeOfDay.ToString & "')"
CMD = New SqlCommand(query, con)
CMD.ExecuteNonQuery()
con.Open()
con.Close()
frmMDIMain.Show()
Me.Hide()
Else
MsgBox("INVALID LOGIN")
End If
txtUsername.Text = ""
txtPasswd.Text = ""
txtUsername.Focus()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Me.Close()
End
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
txtUsername.Text = ""
txtPasswd.Text = ""
txtUsername.Focus()
End Sub
Private Sub LoginForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call myConnection()
txtUsername.Focus()
End Sub
End Class
this is my login form's coding.
Imports System.Data
Imports System.Data.SqlClient
Module ConnectionModule
Public constr As String
Public con As SqlConnection
Public USERNAME As String
Public USERTYPE As String
Public empadd As Boolean
Public employeeid As String
Public SEARCHFOR As String
Public custid As String
Public VOUCHERADD As Boolean
Public source As String
Public MOVIENO As String
Public da As SqlDataAdapter
Public ds As DataSet
Public query As String
Public COMMAND As SqlCommand
Public NO As Integer
Public MOVIENAME As String
Public amount As Double
Public LESSAMT As Double
Public EXT As Boolean
Public logintime As DateTime
Public i As Integer
Public SHOWDATE As Date
Public SHOWTIME As String
Public CATEGORY As String
Public TRANS As String
Public price As Integer
Dim COUNTER As Integer
Public SCNO As String
Public TOTAL As Double
Public Sub myConnection()
constr = "server=(local);Database=MULTIPLEX;trusted_connection=true"
con = New SqlConnection(constr)
End Sub
Public Sub getamount(ByVal TOTAL As Double)
query = "SELECT AMOUNT FROM VOUCHER WHERE CUSTID= '" & custid & "'"
If con.State = ConnectionState.Open Then con.Close()
con.Open()
da = New SqlDataAdapter(query, con)
ds = New DataSet
da.Fill(ds)
amount = ds.Tables(0).Rows(0).Item(0)
If amount < Val(TOTAL) Then
LESSAMT = Val(TOTAL) - amount
amount = 0
MessageBox.Show("INSUFFICIENT BALANCE IN VOUCHER, CUSTOMER HAS TO PAY " & LESSAMT & "BY CASH ")
Else
amount = amount - Val(TOTAL)
End If
End Sub
Public Sub DEDUCTAMOUNT()
If con.State = ConnectionState.Open Then con.Close()
con.Open()
query = "update voucher set amount= " & amount & " where custid='" & custid & "'"
COMMAND = New SqlCommand(query, con)
COMMAND.ExecuteNonQuery()
con.Close()
End Sub
End Module
this is my connection modules coding.
I get
{
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dllAdditional information: Cannot open database "MULTIPLEX" requested by the login. The login failed.
Login failed for user 'magicbox\Administrator'.
}
this run time error. and Ii highliting line 30:con.oprn()
how can I over come from this.
please reply fast...
thnx in advance...
have a nice day..