Showing posts with label keywords. Show all posts
Showing posts with label keywords. Show all posts

Friday, March 23, 2012

How to use tableadapter wizard with vendor specific keywords?

Hi. I really like the new tableadapter wizards and how they can speed up development. However, I'm running into a problem I need help with. I am using the table adapter against DB2 and there are special keywords that the designer isn't allowing.

i.e.
Select field1, field2
from table
for fetch only with ur;

When I enter this into the query wizard and then move off the SQL pane to another pane, the wizard quotes the sql so it looks like so:
Select field1, field2
from table
FOR "fetch" "only" "with" ur;

Hence my predicament. When I try to run this or press the ok button to save the query, it won't run because the odbc driver isn't expecting fetch, only, and with to be in double quotes. Is this a known issue or is there some key token to indicate that the keywords should be left alone.

In case anyone is wondering why this would be a problem, in DB2 the keywords above indicate to not use record locking on a table. In an enterprise situation with potentially thousands of users, record locking is not acceptable. In order for our enterprise to use the new enhancements made in VS 2005 to the tableadapter, we need a way around what the designer is doing.

Please advise.To the moderator of this forum:
This post was moved from the C# IDE forum by someone who didn't understand what I was asking them. I've reposted it with clearer meaning (hopefully). Please remove this post from this forum. It doesn't belong here. I would delete it if I could, but I don't seem to have the button to do it anymore.

Thanks,
Jonsql

How to use string values? I really need help for this. Thanks.

Hello,

I am working with ASP.NET/VB and Microsoft SQL 2000 database.

I have a search form where keywords are submitted.
Consider I write the the keywords 'asp' and 'book'. The results page is called as follows: results.aspx?search=asp%20book

Then I use this script in results.aspx to put the keywords in a string:

Sub Page_Load(sender As Object, e As System.EventArgs)
Dim keywords() As String = Request.QueryString("search").Split(CChar(""))
End Sub

My table is set for FULL TEXT SEARCH.
Consider the SQL when I look for records containing 'asp' and 'book':

SELECT *
FROM dbo.documents
WHERE CONTAINS (*, 'ASP or BOOK')

This SQL looks only for these words. What I need is to look for records that contain the Keywords included in the string keywords().

Can you tell me how to access the string values in the SQL and use it?

Thanks,
Miguel::Can you tell me how to access the string values in the SQL and use it?

Yes. You can not. A sql statement can not access your string variable. No way.

YOu have to handle this from the other side: you have to generate SQL that is correct in the first place. Means: the SQL has to contain all the data you want, so that it does not need to access the string value.

So start from the other end. How does your SQL have to look like (check it in query analyzer), then build code that generates exactly this sql statement. If you have trouble doing so (which I can not believe - I think you basically misunderstand that SQL is just a string that you pass forward and no, it can not connect to your variables anymore), a beginner programmer class will help, as well as any book teaching beginner programming - string manipulation is extremely beginner level.|||Assuming your string array keywords contain two strings "asp" and "book"

you could do this:

Dim s as string
Dim sep as string = ""
dim result as string

For each s in keywords
result = result & sep & s
sep = " OR "
Next

you now have a string var called result that looks like this: "asp OR book"

you then use the result string to help you complete the full sql stringsql