| | |
problem with INSERT INTO command
![]() |
•
•
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: 195
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 5: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: 1523 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 7 429 access activex add application basic beep beginner blackjack c++ calculator cd channel9 click code coffeehouse college column component convert copy creative data database delete designer desktop dissertations dissertationtopic edit error excel file filename form grid group hardware icon image implements installation installer key label list listbox liveperson looping macro mail match memory messagebox microsoft movingranges nice number open prime print printer programmer prompt query random range range-objects readfile reading registration remotesqlserverdatabase report reports retrieve save search sites sort sound spectateswamp sql string sum table tags variable vb vb6 vb6.0 vba vista visual visualbasic web window windows





