| | |
problem with INSERT INTO command
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
Hello reader(s),
In table1 i have 3 columns named: emp_id, month, year. First i'm inserting emp_id from a recordset with validation from a text box. Problem is: In the same row i need to insert data of month and year column from individual text box.
Code should like:
insert into table1 (month, year) value ((textmonth.text), (textyear.text)) where table1(emp_id)=(textid.text)
I'm coding in VB 6.0 and very new with VB 6.0. can any one please help me with SQL code??
In table1 i have 3 columns named: emp_id, month, year. First i'm inserting emp_id from a recordset with validation from a text box. Problem is: In the same row i need to insert data of month and year column from individual text box.
Code should like:
insert into table1 (month, year) value ((textmonth.text), (textyear.text)) where table1(emp_id)=(textid.text)
I'm coding in VB 6.0 and very new with VB 6.0. can any one please help me with SQL code??
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
if your using adodb try this
the cn there is your adodb.connection
if your using adodc just change the adodb to adodc, adodb to data1 if your using DAO. .
Regards,
Ryan Riel
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
set rs as new adodb.recordset rs.open "Select * from table1 where emp_id='" & textid.text & "'", cn, 3, 3 if rs.recourdcount > 0 then rs.open "insert into table1 (id, month, year) value ('" + textid.text + "','" + textmonth.text + "','" + textyear.text + "')", cn, 3, 3 end if set rs = nothing
if your using adodc just change the adodb to adodc, adodb to data1 if your using DAO. .
Regards,
Ryan Riel
Last edited by Ancient Dragon; Feb 15th, 2009 at 6:58 pm. Reason: add code tags
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
Dear Ryan,
Your code is working fine. I got another problem in one of my different INSERT command. the code is:
sql = "INSERT INTO DayWiseRoster (id) select UserOFTheMonth (id) where emp_id='" & txtempid.text & " ' "
This command prompting: DATA TYPE MISMATCHED.
Couldnt find what the problem is. I need such code for data validation. I guess passing integer value with reference of another integer value creates the problem. Is there any different SQL code for passing integer value.
the same command i used in my program for different table. That one is:
ssql=" INSERT INTO UserOfTheMonth (emp_id) SELECT users (Emp_id) where name='" & cboname.text & " ' "
Its working fine but the first one is creating problem. Can any one rid me of it??
Your code is working fine. I got another problem in one of my different INSERT command. the code is:
sql = "INSERT INTO DayWiseRoster (id) select UserOFTheMonth (id) where emp_id='" & txtempid.text & " ' "
This command prompting: DATA TYPE MISMATCHED.
Couldnt find what the problem is. I need such code for data validation. I guess passing integer value with reference of another integer value creates the problem. Is there any different SQL code for passing integer value.
the same command i used in my program for different table. That one is:
ssql=" INSERT INTO UserOfTheMonth (emp_id) SELECT users (Emp_id) where name='" & cboname.text & " ' "
Its working fine but the first one is creating problem. Can any one rid me of it??
![]() |
Similar Threads
- Insert Command problem in vb.net using OleDb (VB.NET)
- Problem with INSERT command into MySQL (PHP)
- WizardSteps-> SQL Insert -> Grab ID field (ASP.NET)
- Problem using the UPDATE command in VBA (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: condition not working under do loop
- Next Thread: Winsock Sending problem
Views: 1231 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





