PDA

View Full Version : سوال: مشکل با استخراج اطلاعات از بانک



toopak
یک شنبه 17 شهریور 1387, 20:12 عصر
سلام دوستان
من یه مشکل برام پیش اومده

یه کد دارم که اینه

Dim cmdsql As New OleDbCommand
Dim inssql As String
cmdsql.Connection = con
If Not SlrTextbox1.Text = "" Then
inssql = "SELECT * FROM tbservices where sid= " & SlrTextbox1.Text
cmdsql.Connection = con
cmdsql.CommandText = inssql
Dim DR As OleDbDataReader
DR = cmdsql.ExecuteReader
If DR.HasRows = True Then
DR.Read()
Label5.Text = DR("sid")
Label3.Text = DR("accname")
Label9.Text = DR("maghsad")
Label7.Text = DR("accadd")
Label11.Text = DR("drname")
End If
End If

وقتی اجرا میکنم در قسمت قرمز
این خطلا رو میده


Data type mismatch in criteria expression.

مشکل از کدوم قسمت کارمه؟

ALI TT
یک شنبه 17 شهریور 1387, 20:49 عصر
Connection رو Open کردی ؟؟؟

toopak
یک شنبه 17 شهریور 1387, 20:53 عصر
Connection رو Open کردی ؟؟؟

بله
وقتی فرم لود میشه
کانکشن هم اوپن میشه

ALI TT
دوشنبه 18 شهریور 1387, 00:01 صبح
توی این دستورت :

inssql = "SELECT * FROM tbservices where sid= " & SlrTextbox1.Text

فیلد sid از چه نوعی هست ؟ عدد ، تکس .... چی ؟

toopak
دوشنبه 18 شهریور 1387, 14:10 عصر
کد رو تغییر دادم درست شد

inssql = "SELECT * FROM tbservices where sid= " & "'" & SlrTextbox1.Text & "'" & ""

ممنون

ALI TT
دوشنبه 18 شهریور 1387, 20:28 عصر
دوست عزیز لقمه رو چرا می پیچونی ؟

اینم میشه که راحت تره :

inssql = "SELECT * FROM tbservices where sid= '" & SlrTextbox1.Text & "'"

در آخر دستوری که نوشتی ، "" برای چی هست ؟؟؟!!!!!

چرا استرینگ ها رو با هم جمع نمی کنی ، این طوری :


"SELECT * FROM tbservices where sid= '" & SlrTextbox1.Text & "'"