Insert statment for two tables


Here is my entire Insert statement. Below.
ContentID is primary_key ID and it is automaticlly created upon this insert, but want to also insert that content id in table Category column ContentId. HELP
Two table insert sort of.


[CODE]
sql = "INSERT INTO Content" & _
"(" & _
"user_id," & _
"CreatedBy," & _
"ContentTypeID," & _
"CatID," & _
"Title," & _
"Author," & _
"RelatedURL," & _
"DownloadURL," & _
"DateAdded," & _
"ShortDesc," & _
"LongDesc," & _
"Display," & _
"EMail," & _
"Filename," & _
"Image1," & _
"Thumbnail," & _
"Expire," & _
"Priority," & _
"Status," & _
"Impressions," & _
"ClickThrus," & _
"AvgRating," & _
"PrevContentId," & _
"NextContentId," & _
"ParentContentId," & _
"DateAlert," & _
"Ratings" & _
") VALUES (" & _
"" & to_sql(user_id,"number") & "," & _
"" & to_sql(CreatedBy,"number") & "," & _
"" & to_sql(ContentTypeID,"number") & "," & _
"" & to_sql(CatID,"number") & "," & _
"" & to_sql(Title,"text") & "," & _
"" & to_sql(Author,"text") & "," & _
"" & to_sql(RelatedURL,"text") & "," & _
"" & to_sql(DownloadURL,"text") & "," & _
"" & to_sql(now(),"date") & "," & _
"" & to_sql(ShortDesc,"text") & "," & _
"" & to_sql(LongDesc,"text") & "," & _
"" & to_sql(Display,"number") & "," & _
"" & to_sql(EMail,"text") & "," & _
"" & to_sql(Filename,"text") & "," & _
"" & to_sql(Image1,"text") & "," & _
"" & to_sql(Thumbnail,"text") & "," & _
"" & to_sql(Expire,"date") & "," & _
"3," & _
"" & to_sql(Status,"number") & "," & _
"0," & _
"0," & _
"0," & _
"" & to_sql(PrevContentId,"number") & "," & _
"" & to_sql(NextContentId,"number") & "," & _
"" & to_sql(ParentContentId,"number") & "," & _
"" & to_sql(DateAlert,"absdate") & "," & _
"0)" & _
""
Posted On: Friday 26th of October 2012 07:36:01 AM Total Views:  436
View Complete with Replies

RELATED TOPICS OF ASP PROGRAMMING LANGUAGE




Unable to insert record to my MSaccess database

I am a newbie here. I am trying to pick up asp lanuguage. I am trying insert a record to my database from my webpage customeradd2.asp Code: CustomerAdd2.asp New Customer
VIEWS ON THIS POST

218

Posted on:

Friday 26th October 2012
View Replies!

check item for specific reservation id before insert new item

i want to check item before insert new item. let say resID = 1052. before that, i have inserted item which is prodNumber = 100 for resID = 1052. then, still at resID = 1052, i insert another item, prodNumber = 100, then an error message will come out. but if i insert item, prodNumber = 100 but for resID = 1047, suppose there is no an error message. that means the sql conditions are at current resID and prodNumber., right
VIEWS ON THIS POST

219

Posted on:

Friday 26th October 2012
View Replies!

Error in syntax insert statement

I have an error in my code somewhere , can someone please help. here is the error Error Type: Provider (0x80004005) Unspecified error /Emedia Studios Website/enquiry_form.asp, line 113 Browser Type: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) Page: POST 244 bytes to /Emedia Studios Website/enquiry_form.asp POST Data: companyname=bert&title=MR&contact=james&primary=01 214578&secondry=1245789&fax=1234567&email=df@dsfdf sdf.com&hear=Internet+Search&calltime=12pm+-+5pm&method=Fax&relates=Templates&enquiry=Please+h elp%0D . . . Here is my code
VIEWS ON THIS POST

249

Posted on:

Friday 26th October 2012
View Replies!

Dreamweaver insert and request.form

, has anyone here had problems trying to retrieve form elements from a dreamweaver insert form I have this page, Code: Untitled Document Name:     Followed by this one: Code: Untitled Document But nothing shows up! Any ideas how I retreive the form elements from the previous page
VIEWS ON THIS POST

252

Posted on:

Friday 26th October 2012
View Replies!

insert drop down list (date) into database

hi, i have drop down list called check in date. Code: Check-in Date : Month January February March April May June July August September October November December   Date 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31   Year 2012 2013 2014 2015 2016 i want to how to insert the check-in date as a short date (example : 1/4/2012) into the access database i kinda know the syntax, but not quite. please help!
VIEWS ON THIS POST

212

Posted on:

Friday 26th October 2012
View Replies!

How can I insert the content from an HTML or ASP page into a DataBase

Hi !! Sorry, that was not so much explicit , what I want to make actually is to take the results of a search engine that I use, which are in form of HTML or ASP and transport that results in a DataBase. For example, I wont to place as registrations in the DataBase the equivalents URLs and their descriptions from the results of search. I use MS Access, code asp, HTML , Javascript . QUESTION!!!! How can I insert the content from an HTML or ASP page into a DataBase\t\t\t\t How can I determine from what point to what point a string it will be entered in the first cell of table and afterwards in the next and next .. \t\t
VIEWS ON THIS POST

212

Posted on:

Friday 26th October 2012
View Replies!

ASP Script inserting to SQL table with image column type

Would someone be able to explain the sql image field to me. I was reading about it a little but dont really understand. I would like to have word documents that can be indexed and searched and i heard the image field with an accompanying char field with the file extension would be the trick. how would i actually get binary files into the image field I wanted to write an asp script so users could enter .doc that they could query. I understand basic asp \ sql inserts.
VIEWS ON THIS POST

240

Posted on:

Friday 26th October 2012
View Replies!

whats wrong with my insert?plss help me...

i seem to get an error like this..i don't seem know why.. Error Type : Microsoft JET Database Engine (0x80040E14) Syntax error in INSERT INTO statement This is my code --------------- set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("_private\fwdb.mdb")) set rs2 = Server.CreateObject("ADODB.recordset") rs2.open"insert into member(user_name,password,first_name,last_name,ema il,address_one,address_two,city,state,zip,country, parea,farea,phone,fax) values ('"&user&"','"&pass&"','"&first&"','"&last&"','"&e mail&"','"&add&"','"&addtwo&"','"&city&"','"&state s&"',"&zip&",'"&country&"',"&areap&","&areaf&","&p hone&","&fax&",)",conn response.Redirect("add1.asp") please help me...
VIEWS ON THIS POST

373

Posted on:

Friday 26th October 2012
View Replies!

inserting javascript 'back' into response.write

hi . i have a setting in one of my asp pages that if a date is entered in the incorrect format then an error message is display Code: Response.write ("Sorry but you entered an incorrect date or date format") i would like to add to this page, along with the error message a response.write that has this code Code: Click to go Back i tried Code: Response.write (" Click to go Back ") but it didnt work as i suspected. The thing is i cant simply add this code at the end of the asp page because this page is a settings page which is being included in many other pages...so i just want to add the javascript back command in the same area.
VIEWS ON THIS POST

238

Posted on:

Friday 26th October 2012
View Replies!

ASP insert query problem

I am experiencing a strange problem attempting to insert data from my ASP to an Access database. The code is as follows: ----------------------------------------------------------------------------------------------------------------------------- sql = "INSERT INTO Employees(EmpID, Name, Salary, UserType) VALUES ('"&NewEmpID&"', '"&Name&"', 0, 'User')" conn.execute(sql) sql = "INSERT INTO TeamMembers(Owner, EmpID) VALUES ('"&Session.Contents("EmpId")&"','"&NewEmpID&"') " conn.execute(sql) sql = "INSERT INTO Hours(EmpID, ActualHours, Month, Year) VALUES ('"&NewEmpID&"', "&Hours&", "&CurrentMonth&", "&CurrentYear&")" response.write sql conn.execute(sql) ------------------------------------------------------------------------------------------------------------------------------ The odd thing is that the Employees and TeamMembers table inserts work perfectly. However, the Hours table insert does not. You'll notice I write out the Hours table insert to the webpage. When I copy this and paste it into a query in the actual database, the insert works and a new record is added to the Hours table properly. Any idea what the problem might be
VIEWS ON THIS POST

203

Posted on:

Friday 26th October 2012
View Replies!

How to insert field by SQL

How to insert fields in a table by using SQL\t\tThx
VIEWS ON THIS POST

269

Posted on:

Friday 26th October 2012
View Replies!

Just a quick issue I have with an insert query

I am having a problem with an insert SQL command, its the sql is not correct. Below is my Sub: Dim sql Sub addArticle() sql = "INSERT INTO tblNews (newsDate, newsTitle, newsBody) " &_ "VALUES ('" & Request.Form("articledate") & Request.Form("articletitle") & Request.Form("articlebody") & ")" dbExecute.Execute(sql) End Sub If I hard code values into the sql instead of the request.form it adds the data fine, but I cannot get my sql right in order to use the form inputs, can someone help and explain what I am doing wrong and explination would help.
VIEWS ON THIS POST

247

Posted on:

Friday 26th October 2012
View Replies!

insert into

I am trying to insert values from a input box in html into a DB2 database. The only value that is put in is det sequense counter. The outher two values gets emty. I dont get any error message.
VIEWS ON THIS POST

177

Posted on:

Friday 26th October 2012
View Replies!

possible to insert Javascript into VBscript?

Is possible to insert, 4 example, a Javascript code into 2 blocks of vbscript code like: awmCreateCSS(1,,1,'#FFFFFF','#5B5B5B',n,'4mm sans-serif',n,'none',2,n,0,4) Thx
VIEWS ON THIS POST

168

Posted on:

Friday 26th October 2012
View Replies!

Trying to get the ID of the last inserted row

Hi all, To cut a very long story short, I need to get the ID of the last inserted row. I *think* I'm writing in VBScript and this is Classic ASP, but as a PHP developer I'm totally out of my depth here. I've been trying to achieve this simple task for two days, and two other forums full of ASP developers can't seem to come up with a solution that works. This is as far as I've got: Code: set rsSelect = server.CreateObject("adodb.recordset") rsSelect.activeconnection = str_connect rsSelect.source = "insert into tbl_newsletter (news_name,news_surname, news_email,news_interested,news_who,news_house,news_postcode,news_magazines, news_referrer, news_hotel) values ('" & v_name & "','" & v_surname & "', '" & v_email & "','" & v_interested & "','" & v_news_who & "','" & v_news_house & "','" & v_news_postcode & "','" & v_news_magazines & "', '" & v_referrer & "', '" & v_hotel & "'); Select TOP 1 id from tbl_newsletter ORDER BY id DESC" rsSelect.open for each x in rsSelect.fields response.write(x.name) response.write(" = ") response.write(x.value) next This echoes nothing out to the screen, I presume because the rsSelect object is empty. Can anyone please help
VIEWS ON THIS POST

223

Posted on:

Friday 26th October 2012
View Replies!

Transactions with multiple insert statements

Im trying to figure out how to use transactions in ASP... Basically I will have 2 insert statements going to 2 different tables and I just want to make sure that if there are any errors then it rolls back. So far I have this with 1 insert statement (havent written the second yet): PHP Code: conn.BeginTrans SQLInsert="InsertintoLogins(Username,Password,SchName,Access)Values('"&_ Username&"','"&Password&"','"&SchoolNm&"','"&Access&"')" conn.ExecuteSQLInsert IfInvalid\t1ANDExists\t1Then 'IfallthevalidationhasbeenmetruntheSQL. conn.CommitTrans Success="Loginhasbeencreatedsuccessfully!" Else conn.RollbackTrans Success="Therewasanerrorduringthetransaction" conn.Close EndIf This statement: If Invalid 1 AND Exists 1 Then is just basically calling validation from some if statements before the insert... but im thinking if theres a connection error or if there is some other problem it wont rollback. So is there some global way of checking for any errors at all Table errors, data type errors etc etc.. Or should I be using a stored procedure in SQL server 2k
VIEWS ON THIS POST

140

Posted on:

Friday 26th October 2012
View Replies!

Code changes when inserted in edit forms

I am developing a website using Dreamweaver, ASP and Access databases. I have set up a database with information on books including URL links to sites and also to graphics, and when the relevant page takes the information from my uploaded database, it works perfectly. However, I have also set up pages to edit the information and also to insert new information, and when I insert information in this way, the url and graphic links in the resulting pages are somehow changed because the "" values are changed to []. Has anyone else experienced this, or can anyone suggest how I can get over this problem The information in the database on the server is unchanged, it is just in the resulting code that it changes.
VIEWS ON THIS POST

312

Posted on:

Friday 26th October 2012
View Replies!

need guidance in inserting field ( coding question )

I want to insert is the "new_gemetria" field. Is it necessary to enter all the "p_"s as shown below. Since all the rest of the fields are already inserted. Code: if linkSet.EOF then p_new_id = 1 else p_new_id = linkSet("new_id") + 1 end if p_new_id_in = Request.querystring("p_new_id") if p_new_id_in "" then linkSet.Find "new_id = " & p_new_id_in end if if p_new_id_in = "" or linkSet.EOF then p_new_recordType = "" p_new_book_spoke = "" p_new_chapter_spoke = "" p_new_verse_spoke = "" p_new_book = "" p_new_chapter = "" p_new_verse = "" p_new_text_data = "" p_new_gemetria = "" else p_new_id = p_new_id_in p_new_recordType = linkSet("new_recordType") p_new_book_spoke = linkSet("new_book_spoke") p_new_chapter_spoke = linkSet("new_chapter_spoke") p_new_verse_spoke = linkSet("new_verse_spoke") p_new_book = linkSet("new_book") p_new_chapter = linkSet("new_chapter") p_new_verse = linkSet("new_verse") p_new_text_data = linkSet("new_text_data") p_new_gemetria = linkSet("new_gemetria") p_existing = p_new_id_in end if , I thought of another method because this seems too complicated. How about including a textarea wherein is the calculation inserted automatically next to each record (therefore a textarea next to each record) and a submit button on top of the "textarea column". I tried this but it has some problems: since the page holds 10 records at a time what it's doing is taking the result from the 10 records and updating in one record (is one square called parameter). So 10 in 1. Here's the link: http://k.domaindlx.com/gemetria/pageing2.asp
VIEWS ON THIS POST

271

Posted on:

Friday 26th October 2012
View Replies!

Error on inserting data in database

please help me .. i always got this error that cannot save data on access database because the folder where it is is in read-only mode, what will i do.. tnx in advance!
VIEWS ON THIS POST

291

Posted on:

Friday 26th October 2012
View Replies!

Insert Multiple records into Table - Not inserting Data (MS Access)

I have a page displaying records from tableA. each repeat region has 3 checkboxes and hidden filed containing record_ID. I want to insert the ID from each record along with the checkbox inputs, into tableB. I am using a counter to assign an individual name to each of the form components on my page . I am submitting my form to a page (input_data.asp), but nothing is inserting into the database, I am just getting sent to input_data.asp and getting all the form values passed in the url. 0 Then Dim iCount, iLoop, varFront, varRear, varInterior, varID icount = request("tCnt") 'is the number of records to be updated set Insert_vehicle = Server.CreateObject("ADODB.Command") Insert_vehicle.ActiveConnection = MM_conn_vehicleDB_STRING For iLoop = 1 to iCount if (request(iloop & ".front") "") then Insert_vehicle__varFront = Request (iLoop & ".front") if (request(iloop & ".rear") "") then Insert_vehicle__varRear = Request (iLoop & ".rear") if (request(iloop & ".interior") "") then Insert_vehicle__varInterior = Request (iLoop & ".interior") if (request(iloop & ".requestID") "") then Insert_vehicle__varID = Request (iLoop & ".requestID") Insert_vehicle.CommandText = "INSERT INTO tableB (request_ID, taken_front, taken_interior, taken_rear) VALUES ('" + Replace(Insert_vehicle__varID, "'", "''") + "', '" + Replace(Insert_vehicle__varFront, "'", "''") + "', " + Replace(Insert_vehicle__varInterior, "'", "''") + "', " + Replace(Insert_vehicle__varRear, "'", "''") + ") " Insert_vehicle.CommandType = 1 Insert_vehicle.CommandTimeout = 0 Insert_vehicle.Prepared = true Insert_vehicle.Execute() Next set Insert_vehicle = Nothing Response.Redirect("name_select.asp") End if %> I am using dreamweaver MX 2004 and trying to handcode the insert page (my asp skills are far from capable). can anyone help
VIEWS ON THIS POST

179

Posted on:

Friday 26th October 2012
View Replies!