12-04-14, 11:06 PM
السلام عليكم اخوانى عندى مشكله فى ذالك المشروع عند ادخال اليوزر والباس المسجل فى الداتا يظهر الخطا هذا
an attempt to attach an auto-named database for file failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
المشروع مرفق
وهذا الاكواد
Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
Class1.sqlcon.ConnectionString = "Data Source=A-PC\SQLEXPRESS;;AttachDbFilename=|DataDirectory|test.mdf;integrated security=true;Connect Timeout=30;"
MsgBox("Done", MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub txtNumber_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtNumber.KeyPress
If Char.IsControl(e.KeyChar) = False Then
If Char.IsDigit(e.KeyChar) Then
Else
e.Handled = True
End If
End If
End Sub
Private Sub BtnLogin_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click
If txtNumber.Text = "" Then
MsgBox("enter number acc", MsgBoxStyle.Exclamation, "try")
txtNumber.Focus()
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox("enter password", MsgBoxStyle.Exclamation, "error")
txtPassword.Focus()
Exit Sub
End If
Try
Dim str As String = "select userid,userpassword from users where userid=" & txtNumber.Text & "and userpassword='" & txtPassword.Text & "'"
Dim sd As New SqlDataAdapter(str, Class1.sqlcon)
Dim ds As New DataSet
sd.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Me.Hide()
frmmain.Show()
Else
MsgBox("Error data", MsgBoxStyle.Exclamation, "error")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
an attempt to attach an auto-named database for file failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
المشروع مرفق
وهذا الاكواد
Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
Class1.sqlcon.ConnectionString = "Data Source=A-PC\SQLEXPRESS;;AttachDbFilename=|DataDirectory|test.mdf;integrated security=true;Connect Timeout=30;"
MsgBox("Done", MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub txtNumber_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtNumber.KeyPress
If Char.IsControl(e.KeyChar) = False Then
If Char.IsDigit(e.KeyChar) Then
Else
e.Handled = True
End If
End If
End Sub
Private Sub BtnLogin_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click
If txtNumber.Text = "" Then
MsgBox("enter number acc", MsgBoxStyle.Exclamation, "try")
txtNumber.Focus()
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox("enter password", MsgBoxStyle.Exclamation, "error")
txtPassword.Focus()
Exit Sub
End If
Try
Dim str As String = "select userid,userpassword from users where userid=" & txtNumber.Text & "and userpassword='" & txtPassword.Text & "'"
Dim sd As New SqlDataAdapter(str, Class1.sqlcon)
Dim ds As New DataSet
sd.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Me.Hide()
frmmain.Show()
Else
MsgBox("Error data", MsgBoxStyle.Exclamation, "error")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class