PDA

View Full Version : سوال: مشکل با گرید تلریک



barnamenevisjavan
چهارشنبه 09 اسفند 1391, 14:03 عصر
سلام من دارم از گرید تلریک برای نمایش اطلاعت دیتابیس اکسس استفاده میکنم ولی نمیدونم چرا کد زیر کار نمیکنه و اطلاعاتو نشون نمیده.
Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\Database1.mdb"
Dim my_con As New OleDbConnection(cs)
Dim DA As New OleDbDataAdapter
Dim d As String
Public Sub SelectAllfield()
Try
DA.SelectCommand = New OleDbCommand()
With DA.SelectCommand
.Connection = my_con
.CommandType = CommandType.Text
.CommandText = "Select id,p_Fname as [تست],p_MName as [تست],p_TT as [تاریخ فعال ],p_Tedad as [تست]," & _
"p_MDaryafti as [مبلغ دریافتی],p_Comment as [توضیحات],p_Mgero as [تست],p_jender as [تست],p_tel as [تست] from Table1"
If .Connection.State <> ConnectionState.Open Then
.Connection.Open()
End If
.ExecuteNonQuery()
Dim dt As New DataTable
DA.Fill(dt)
grdPersons.DataSource = dt
End With
my_con.Close()
Catch ex As Exception
MsgBox("مشكل در ارتباط با ديتابيس،از وجود دیتابیس مطمئن شوید", MsgBoxStyle.Exclamation, "اخطار")
End Try
End Sub


Private Sub editform_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SelectAllfield()
'grdPersons.Columns(0).Visible = False
Try
DA.SelectCommand = New OleDbCommand()
With DA.SelectCommand
.Connection = my_con
.CommandType = CommandType.Text
If .Connection.State <> ConnectionState.Open Then
.Connection.Open()
End If
End With
my_con.Close()
Catch ex As Exception
MsgBox("مشكل در ارتباط با ديتابيس،از وجود دیتابیس مطمئن شوید", MsgBoxStyle.Exclamation, "اخطار")
End Try
End Sub