0

I have a working dataset and datagrid already in my project, but I want to make my own quicksearch button. The following code gives error for connectionstring PROVIDER KEYWORD NOT SUPPORTED

connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\prod.mdb"

sql = "Select (*) from table1 where prodid=" + searchfield.Text

cnn = New SqlConnection(connetionString)
Try
    cnn.Open()
    cmd = New SqlCommand(sql, cnn)
    Dim ret = (cmd.ExecuteScalar())
    cmd.Dispose()
    cnn.Close()
    Text = ret
1
  • 1
    Shouldn't you be using OleDbConnection instead of SQLConnection ? SQLConnection is for SQLServer Commented Jun 2, 2009 at 7:47

2 Answers 2

4

Are you trying to just search for a particular value in field or asking for a full blown query designer?

If it is the first one, should be relatively easy, you can either select the rows directly in the datagrid or fire a paramaterized query to get the result.

If it is the second, things are slightly more complicated. You might have to use a third party component.

As requested :-)

You are using wrong Connection. You should be using OleDbConnection class. I hate to nitpick, but you are generating SQL Statements on the fly by String concatenation which leaves you open to SQL Injection attacks

Sign up to request clarification or add additional context in comments.

3 Comments

I was more looking for info how to make a sql query like: data.executeSql("select xxxx where a="+mykey)
You are using wrong Connection. You should be using OleDbConnection class. I hate to nitpick, but you are generating SQL Statements on the fly by String concatenation which leaves you open to SQL Injection attacks.
@no_one if you put that last comment into your answer I'll vote it up
0

its better to use

dataset.table.select("a=b")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.