More Visual Basic Answers
Question Library
Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login
Awards
About Us
Tell friends
Link to Us
Disclaimer
|
| |
|
|
| |
| | | |
About Ravindra
Expertise visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.(VB6)
basic questions in vb 2008.
Optional:
1)a large number of people want me to do work which takes some time and effort. can do projects in vb 2008. Pl.note that i would like to be paid for such work.
2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time.
3) if you are pleased with my reply you could consider a donation of 1$.
4) you can visit my website http://ravindra.coolpage.biz
Experience
Education/Credentials engineering, management degrees.
Past/Present Clients project work for a Norway company,USA company and a Canadian company completed. Freelance Project work and Teaching. helping programmers with their work
teaching vb
| | |
| |
You are here: Experts > Computing/Technology > Basic > Visual Basic > VB problems
Expert: Ravindra - 10/21/2009
Question
I want to check a text box value with sql2000 server db using sql query and show the new form. Where as I can’t compare the value
Please see the coding and attachment and help me where I have done the mistake & tell me how to compare the database value in if statement using sql query, what I am doing is
Private Sub Print_Cmd_Click()
Databse connection has been already opened using connection string even though i opening again
Dim Connection As New ADODB.Connection
Dim Command As New ADODB.Command
Dim eid As String
Dim strsql As String
Set Connection = New ADODB.Connection
Connection.ConnectionString = "driver={SQL Server};server=SRV-FTZ-SQL;uid=sa;pwd=;database=exactpayroll"
Connection.Open
Command.ActiveConnection = Connection
eid = Empid_txt.Text
strsql = " SELECT empid FROM EmployeeMaster where empid= & eid "
If strsql = eid Then
Prt_Msg.Show
Else
MsgBox (" Please enter a valid Employee id")
End If
End Sub
Can you please help
Now you can see the data grid has the database value I am giving a Id which is present in the data base , but it executes the else statement
Answer strsql is just a string and not the recordset's field value
you need to open it as
dim rec as adodb.recordset
'set rec=new adodb.recordset
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
if rec.fields(fieldname/number)=eid ( you need to convert to Val(empid_txt.txt))
then
...
rec.close
Ask a Question
|
|