Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Friday, March 23, 2012

Help creating a Transact SQL Insert Statement

Hi there can anyone help me to create a SQL Insert Statement. I dont know SQL at all.

To explain, I have two web pages. search.asp and results.asp.

search.asp has the following.

Form Name: searchForm
Set to: Post
Action: results.asp
Text Field: Keyword
Drop Down: CategoryTable
Drop Down: Location
UserName Session Variable: MM_UserName

results.asp has the following SQL which pulls all the results.

SELECT SupplierName, Location, ShortDescription, TimberSpecies, CategoryTitle, Country, CustomerType
FROM Query1
WHERE TimberSpecies LIKE '%MMColParam%' AND CategoryTitle LIKE '%MMColParam2%' AND Location LIKE '%MMColParam3%' AND CustomerType = 'Trade/Retail'
ORDER BY CategoryTitle, TimberSpecies ASC

The database & form I want to insert into.

tblSearcheResults
idSearch (AutoNumber)
location (Text) "Want to insert the 'Location' result here"
category (Text) "Want to insert the 'CategoryTable' result here"
user (Text) "Want to insert the UserName Session Variable result here"
result (Text) "Want to insert the 'Keyword' result here"

Please ask if u need more info.

Mally

Hi,

INSERT INTO tblSearchResults
(
location,
category,
user,
result
)
VALUES
(
Location, --should be due to the POST action in Request.Form("Location")
category, --should be due to the POST action in Request.Form("category")
user, --should be due to the POST action in Session("MM_UserName")
keyword, --should be due to the POST action in Request.Form("keyword")
)

Variable have to be read first and the query string to be constructed before sending it to SQL Server, keep in mind that you have to quote the string while composing the SQL String.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

Wednesday, March 21, 2012

Help connecting pages which has Database connection.

I am a completely new asp.net / SQL server user.
I've been only working with PHP + MYSQL server before which is very different.

There are databases which come with the SQLserver, such as "master"
and there are databases which i create by my own.

When using "master" database, everything works fine.
here's a screenshot.
http://img528.imageshack.us/img528/57/d1if7.jpg

but when using database which i created by my own, i get an error
whether i use ip or localhost.
http://img513.imageshack.us/img513/4598/d2iz7.jpg

only when i use the debugger, it gives me some port, then i am able to connect but only using localhost... therefore i can't give the adress to anyone else.
http://img528.imageshack.us/img528/3394/d3jn6.jpg

What's the difference between the Built in databases and those i create?
how can i make that i could access pages which has database connection to databases i created by my own??

Sorry for my English, i know it's not really understandable.Anyone? it seems like something which everyone who uses asp.net with sql server for a while should know.
ty.

Friday, February 24, 2012

Help

This is my error and I need help figuring out why I am getting this error.
I am trying to get my sql query to display on the pages as I want to request. But it is creating some kind of code conflict.

Microsoft VBScript compilation (0x800A03EA)
Syntax error
/nsex707/common/i_webpart_col_left.do, line 104
sub request_featured_content2

Here is the CODE
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dim featured_content_sql2

sub request_featured_content2
ContentTypeID = request("ContentTypeID")
FeaturedLabel = request("FeaturedLabel")
Thumbnail = request("Thumbnail")
Display = request("Display")
ContentID = request("ContentID")
ContentType = request("ContentType")
ContentTitle = request("ContentTitle")
iftest = request("iftest")
ShortDesc = request("ShortDesc")
elsetest = request("elsetest")
LongDesc = request("LongDesc")
endtest = request("endtest")
iftest_ads = request("iftest_ads")
AdTitle = request("AdTitle")
AdBanner = request("AdBanner")
endiftest_ads = request("endiftest_ads")
end sub

sub validate_featured_content
''' request and validate data entered from this form
ContentTypeID = trim(request("ContentTypeID"))
FeaturedLabel = trim(request("FeaturedLabel"))
Thumbnail = trim(request("Thumbnail"))
Display = trim(request("Display"))
ContentID = trim(request("ContentID"))
ContentType = trim(request("ContentType"))
ContentTitle = trim(request("ContentTitle"))
iftest = trim(request("iftest"))
ShortDesc = trim(request("ShortDesc"))
elsetest = trim(request("elsetest"))
LongDesc = trim(request("LongDesc"))
endtest = trim(request("endtest"))
iftest_ads = trim(request("iftest_ads"))
AdTitle = trim(request("AdTitle"))
AdBanner = trim(request("AdBanner"))
endiftest_ads = trim(request("endiftest_ads"))
end sub

sub db_select_featured_content2
Featured_Content_Sql2 = "SELECT TOP 3 ContentID, ContentType, Thumbnail, FeaturedLabel, ShortDesc, LongDesc, Title AS ContentTitle " & _
"FROM (Content LEFT JOIN ContentTypes ON Content.ContentTypeId = ContentTypes.ContentTypeId) " & _
"WHERE ContentTypes.ContentTypeId <> 1 AND Enabled=1 AND Feature=1 ORDER BY Priority, DateAdded DESC"
end sub

''' request form keys and inputs
ContentID = request("ContentID")

':: request action
action = lcase(request("action"))

':: handle the action
select case action

case "select_featured_content2"
' select the requested key record from database
if ContentID <> "" then
db_select_featured_content2
else
b_error = true
error_list.add "edit_featured_content", "Specify record to select."
end if

end select

':: handle the default case(s) (ignores value of action parameter)

%>

This seems to not be related to either ASP.NET or ADO.NET.