need help in vb 6 programming

rabjabber

Journeyman
so there is this school project i am developing
i made a mistake and started and completed all the form in vb 10. and then my teacher told me that i require to redo the project in vb6, so i was wondering if there is any way to copy all the forms from vb 10 to vb 6 as it is
 

Santa Maria!

Journeyman
I doubt it. Visual Basic went through a MASSIVE change after VB6. It became VB.NET and runs in the .NET environment. They are considered different languages now.
Best start with the manual labour.
 
OP
R

rabjabber

Journeyman
guys, i need more help.
so i connected all the screens, made all the databases in MS access and connected them to the respective adodc's
now 4 out of 5 have to be connected to datagrids which i already did.
but the last one has to add data to a database. which i have no clue how to do??
can you tell me the steps to be followed to input some data in textboxes click a button and take all that data to a database made in ms access and connected to a adodc on that form?
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Visual Basic Tutorial Lesson 25:Creating VB database applications using ADO control

adding record to the database using adodc in vb6 | DaniWeb

VB6 Using ADO Data Control

Hope that helps :)
 
OP
R

rabjabber

Journeyman
that helped to some extent. i tried with just one textbox giving data to one field in a table with multiple feilds. worked like a charm

but when i coded for all the fields it gave me the following error
run-time error '-2147217887 (80040e21)':
multi-step operation generated errors. check each status value



btw i'm using office 2010 and vb6
 

krishnandu.sarkar

Simply a DIGITian
Staff member
That runtime error generally means type mismatch. Checkout the values you are passing to the fields.

Checkout run-time error (80040e21) Multiple-step OLE DB-VBForums and Answer : what is "Multiple-step operation generated errors" Run-time error (80040e21) ?
 

Shah

Cyborg Agent
that helped to some extent. i tried with just one textbox giving data to one field in a table with multiple feilds. worked like a charm

but when i coded for all the fields it gave me the following error
run-time error '-2147217887 (80040e21)':
multi-step operation generated errors. check each status value



btw i'm using office 2010 and vb6
Just post that part of code. I can help you with it.
 
OP
R

rabjabber

Journeyman
Just post that part of code. I can help you with it.

Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("Staff_Name") = Text1.Text
Adodc1.Recordset.Fields("Staff_ID") = Text2.Text
Adodc1.Recordset.Fields("Age") = Text3.Text
Adodc1.Recordset.Fields("Address") = Text4.Text
Adodc1.Recordset.Fields("DOB") = Text6.Text
Adodc1.Recordset.Fields("Father's Name") = Text7.Text
Adodc1.Recordset.Fields("Education/Qualification") = Text8.Text
Adodc1.Recordset.Fields("Job Description") = Text9.Text
Adodc1.Recordset.Fields("Date of Joining") = Text10.Text
Adodc1.Recordset.Fields("initial salary") = Text11.Text
Adodc1.Recordset.Fields("Contact no") = Text12.Text
Adodc1.Recordset.Fields("2nd Contact") = Text13.Text
Adodc1.Recordset.Update
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Ok two things that comes into my mind is, I guess you need to use Adodc1.Recordset.Fields("Staff_Name").Value = Text1.Text

Another thing I notice is Staff_ID, Age, Date of Joining, initial salary etc. may be int / DateTime in your database. So please check that. You need to cast the values according to that. Otherwise you'll get runtime error.

Also never name database fields with space, it creates problem sometimes, generally use _ instead of space.
 
OP
R

rabjabber

Journeyman
Ok two things that comes into my mind is, I guess you need to use Adodc1.Recordset.Fields("Staff_Name").Value = Text1.Text

Another thing I notice is Staff_ID, Age, Date of Joining, initial salary etc. may be int / DateTime in your database. So please check that. You need to cast the values according to that. Otherwise you'll get runtime error.

Also never name database fields with space, it creates problem sometimes, generally use _ instead of space.

that is what i meant by input filters





anyways doesn't matter coz i tried your solutions. didn't work
thnx for your time though
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Those are field type, you need to set some field type. It's not possible to set no field type for a field.

But to get your existing code going, you can set them as Varchar (Text in Access)
 
OP
R

rabjabber

Journeyman
that's what i did

i got past that error by redoing my database
but now it's giving a different error


run-time error '-2147217904 (80040e10)':
[Microsoft][ODBC Microsoft Access Driver] COUNT field incorrect
 

krishnandu.sarkar

Simply a DIGITian
Staff member
^^You mean by converting those fields to Text, your code worked right?

Anyway, the last runtime means you are missing some field. I mean may be you are not passing value for some NOT NULL Field.
 

krishnandu.sarkar

Simply a DIGITian
Staff member
@rabjabber Bro, may be the fields in database are NOT NULL fields, it means the fields cannot have NULL Value i.e. no value at all. So while inserting you have to provide values for them.

OR you need to declare those fields as NULL Fields, means those fields can have NULL value.

And you said that your code worked with one fields and not working when you are leaving 3 - 4 fields blank. Are you sure, you are not leaving the Primary Key field?

May be your database have all the fields set to NULL, but you were inserting Primary Key field that time. But now on your code may be you are not inserting Primary Key field. Primary Key fields cannot be NULL at all.

Hope you get what I mean.
 
Top Bottom