ورود

View Full Version : اشكال در رفتن به ركورد قبلي و اولين ركورد در ADODB



alireza96
سه شنبه 01 بهمن 1387, 11:11 صبح
سلام
من يك بانك sql server را از طريق كد نويسي adodb به vb وصل كردم همه چيز درسته ولي به ركورد قبلي و ركورد آخر نميرود و خطا ميدهد لطفا در اين باره كمكم كنيد :اشتباه:




ماژول

Option Explicit
Public strcon As New ADODB.Connection
Public cmd As New ADODB.Command
Public rs As New ADODB.Recordset
Public Sub connect(s As String)
cmd.ActiveConnection = strcon
cmd.CommandText = s
Set rs = cmd.Execute
End Sub
Public Sub fill()
If Not (rs.EOF = True Or rs.BOF = True) Then
Form1.Text1.Text = rs("stuid")
Form1.Text2.Text = rs("stufname")
Form1.Text3.Text = rs("stulname")
Form1.Text4.Text = rs("stufather")
End If
End Sub
Sub main()

Form1.Show

End Sub

فرم
Private Sub cmddel_Click()
cmd.ActiveConnection = strcon
intn = InputBox("ÔãÇÑå ÏÇäÔÌæíí ãæÑÏ äÙÑ ÌåÊ ÍÐÝ ÑÇ æÑÇÏ ˜äíÏ")
cmd.CommandText = "delete from stutbl where stuid=" + Str(intn)
Set rs = cmd.Execute
End Sub
Private Sub cmdfind_Click()
With rs
.Filter = "stuId=" & Val(Label1.Caption)
.Fields("stufame").Value = Text2.Text
.Fields("stulname").Value = Text3.Text
.Fields("stufather").Value = Text4.Text
End With
End Sub
Private Sub cmdFirst_Click()
If rs.BOF = False Then
rs.MoveFirst
Call fill
End If
End Sub
Private Sub cmdinsert_Click()
With rs
.AddNew
.Fields("stuid").Value = Text1.Text
.Fields("stufame").Value = Text2.Text
.Fields("stulame").Value = Text3.Text
.Fields("stufather").Value = Text4.Text
.UpdateBatch adAffectAllChapters
.Requery
End With
Call fill
End Sub
Private Sub cmdLast_Click()
k = rs.MaxRecords
If rs.EOF = False Then
rs.MoveLast
Call fill
End If
End Sub
Private Sub cmdn_Click()
Dim N As Long
rs.MoveFirst
N = Val(InputBox("ÔãÇÑå ÑßæÑÏ ÑÇ æÇÑÏ ßäíÏ", "æÑæÏ ÏÇÏå"))
rs.Move N - 1
Call fill
End Sub
Private Sub cmdNext_Click()
If rs.EOF = False Then
rs.MoveNext
Call fill
End If
End Sub
Private Sub cmdPrevious_Click()
If rs.BOF = False Then
rs.MovePrevious
Call fill
End If
End Sub

Private Sub Command2_Click()
Form1.Hide
End Sub
Private Sub Form_Load()
strcon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pardis"
strcon.Open


Call connect("select * from stutbl")
Call fill
End Sub