Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,290 members, 7,807,984 topics. Date: Thursday, 25 April 2024 at 01:23 AM

Post Your Vb6 Or Vb.net Problems Here - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Post Your Vb6 Or Vb.net Problems Here (2258 Views)

For A Beginner - VB6 Or VB 10 / Login Code In Vb6.0 / Help me convert this Vb6.0 code To Vb.net (2) (3) (4)

(1) (Reply) (Go Down)

Post Your Vb6 Or Vb.net Problems Here by dejisys(m): 11:30am On Oct 10, 2006
If you get stuck in vb, post your problems here.
Re: Post Your Vb6 Or Vb.net Problems Here by skyhadi16(m): 5:09pm On Oct 10, 2006
I want 2 start learning frm scratch can you help me?
Re: Post Your Vb6 Or Vb.net Problems Here by skyhadi16(m): 5:10pm On Oct 10, 2006
I want 2 start learning frm scratch can you help me?
Re: Post Your Vb6 Or Vb.net Problems Here by rookie(m): 6:13pm On Oct 11, 2006
I am trying to copy data from another dataset then save the new dataset into my database. Below is my code. The line hightlighted in red assigns my dataset (containing copied data) to the grid's datasource and displays the copied data just fine. However, after calling the DBAdapter.Update, the copied data is not commited into my database.

In a Nutshell -- The output displayed on the grid contains copied data while the data updated to the database doesnt. Can tell what i'm doing wrong?

Thanks

===============================================================================

Private Sub UpdateDataBase(ByVal ds As DataSet)

Dim dbConnString As String

Dim dbConnection As SqlConnection = New SqlConnection
dbConnection.ConnectionString = "Data Source=ServerName; Initial Catalog=DB;" & _
"UID=uid;PASSWORD=psw; Trusted_Connection=false"
dbConnection.Open()

Dim DBCmd As SqlCommand
DBCmd = New SqlCommand("Select * from [Table1]", dbConnection)

Dim DBAdapter As New SqlDataAdapter
DBAdapter.SelectCommand = DBCmd

Dim DBds As New DataSet
DBAdapter.Fill(DBds, "Table1"wink

DBds = ds.Copy()
DBds.AcceptChanges()
DBAdapter.Update(DBds.Tables("Table1"wink)
DataGrid1.DataSource = DBds.Tables(0).DefaultView
DataGrid1.DataBind()

DBds = Nothing
DBAdapter = Nothing
DBCmd = Nothing
ds = Nothing

End Sub
Re: Post Your Vb6 Or Vb.net Problems Here by Seun(m): 9:04pm On Oct 15, 2006
Hello Deji,

This is to say that you're a VIsual Basic expert, right?
Re: Post Your Vb6 Or Vb.net Problems Here by IG: 4:42pm On Apr 09, 2007
@rookie, I think the problem is that you did not specify an updatecommand for the dataAdapter.
The code in blue is my addition to your code.

Private Sub UpdateDataBase(ByVal ds As DataSet)

Dim dbConnString As String

Dim dbConnection As SqlConnection = New SqlConnection
dbConnection.ConnectionString = "Data Source=ServerName; Initial Catalog=DB;" & _
"UID=uid;PASSWORD=psw; Trusted_Connection=false"
dbConnection.Open()

Dim DBCmd As SqlCommand
DBCmd = New SqlCommand("Select * from [Table1]", dbConnection)

Dim DBAdapter As New SqlDataAdapter
DBAdapter.SelectCommand = DBCmd

Dim builder as new SqlCommandBuilder
builder.DataAdapter = DBAdapter
DBAdapter.UpdateCommand = builder.getUpdateCommand
DBAdapter.InsertCommand = builder.getInsertCommand


Dim DBds As New DataSet
DBAdapter.Fill(DBds, "Table1"wink

DBds = ds.Copy()
DBds.AcceptChanges()
DBAdapter.Update(DBds.Tables("Table1"wink)
DataGrid1.DataSource = DBds.Tables(0).DefaultView
DataGrid1.DataBind()

DBds = Nothing
DBAdapter = Nothing
DBCmd = Nothing
ds = Nothing

End Sub

The DataAdapter needs to know the SELECT, INSERT,UPDATE and DELETE statements to use against the database.
You have already specified the SELECT sql but the remaining are missing.
I used the sqlCommandbuilder to build the remaining sql statements so you wont have to do it manually.
Hope this helps.
Re: Post Your Vb6 Or Vb.net Problems Here by rookie(m): 6:25pm On Apr 09, 2007
I figured out the problem a while back.


Thanks, though
Re: Post Your Vb6 Or Vb.net Problems Here by beysoft: 5:49pm On Apr 17, 2007
Pls i'm a new fellow in vb area
Pls i need someone to help with code using ado
to Connect to ms access dbase using Application Path

2. To Add record
3. To Update Record
4. Delete Record

5. Move First,Next,Previous, Last record
6. Search Record.
I will very gratefull for ur help thnks
My mail is vb_4all@yahoo.com
Re: Post Your Vb6 Or Vb.net Problems Here by ogbon: 12:06pm On Apr 18, 2007
hello,
i have tried to create a word doc using the code below

Open "c:\My Documents\sample.doc" For Output As #1
Print#1,
Print#1,
Close#1,

but i want to be able to access the document at a run time from vb without closing the vbproject, please how can i achieve this, i will be very grateful if you can help me out and if there is anything wrong with the code help me correct it you can send reply to my mail olatunbosunone@hotmail.com

thanks
Re: Post Your Vb6 Or Vb.net Problems Here by luckyCO(m): 12:18pm On Apr 19, 2007
I create a dll file in VB.net converted it vb6.0 dll but I could not see all the public properties. What will I do?
Re: Post Your Vb6 Or Vb.net Problems Here by carliecode(m): 5:02pm On Apr 19, 2007
This is for rookie. besides the correction. its always good for ur dataset to to be updated against a dataadater before u call the acceptchanges method.

ajiboye a.a
mcp(70-306) perfect score
Re: Post Your Vb6 Or Vb.net Problems Here by Dynast(m): 5:40pm On Apr 19, 2007
Have a problem on : A program or subroutine to solve
1-- Matrix Multiplication of any order
2--Determinant of a matrix
3--Cofactor of a matrix
4--Inverse of a Matrix
5--rank of a matrix
6--Guassian elimination
7--Triangular decomposition
8--differential equation of order 3
Re: Post Your Vb6 Or Vb.net Problems Here by IG: 7:20pm On Apr 19, 2007
@ogbon, the following article might guide you
http://www.vbforums.com/archive/index.php/t-121667.html

@Dynast, programmatically, a matrix is simply a 2-dimensional array.
e.g to create a 4X4 matrix you do something like this

Dim Matrix(3,3) as integer

That is if your array index starts from zero.
As for the rest. I think am not in a very good position to study for you smiley

Hey where's dejisys. I thought he's ready to help, that's why he started this topic.
Re: Post Your Vb6 Or Vb.net Problems Here by masterd1(m): 2:52pm On Apr 20, 2007
how do i connect my access database to my form in visual basics
Re: Post Your Vb6 Or Vb.net Problems Here by IG: 4:23pm On Apr 22, 2007
master d:

how do i connect my access database to my form in visual basics

Alright this is a really quick solution.
Assuming your database is C:\mydb.mdb and you have a table called data and fields firstname and othernames in the table.

1- go to reffrences under projects and select Microsoft ActiveX Data Objects 2.x

2- Somewhere in your code type the following

Dim Con as new ADODB.Connection
Dim rsData as new ADODB.Recordset


Con.ConnectionString = "Provider = Microsoft.Jet.Oledb.4.0; Data Source = C:\mydb.mdb"
Con.Open

rsData = Conn.Execute("Select * From Data"wink


At this point your recordset(rsData) will be filled with the records from your table(Data)
You can go ahead and manipulate the data in the recordset.


This is only suppose to be a pointer. One cannot give a full ADO tutorial here. Do some googling
and you will find a lot of resources.

Just an advice. I think instead of putting a lot of effort learning vb6 you should just move to vb.net.
vb6 is getting obsolete and its no longer supported by it's creators (Microsoft).
Re: Post Your Vb6 Or Vb.net Problems Here by carliecode(m): 9:55am On Apr 23, 2007
this is my 2nd reply to this issue.
solution

specify the updatecommand and set its appropriate requirements.
it is important
call the Update method of the dataadapter.
call the acceptchanges.

this is how datasets work
when u call update, it checks all the rows on the dataset object u want to update to c if the rowstatechanged property is true
if it is true, it updates on the database.
however, calling acceptchanges b4 update, sets the rowstatechanged property to false thus, when update is called , no rowchange is detected and so updates are not made.

this is a standard MCAD,MCSD question. there is no other solution as regards dis issue. if you need more info, mail me at callcarliecode@yahoo.co.uk . i av passed 70-306 with 100% score and im writing 70-305 this wk. i av used dotnet 4 abt 6yrs. i am so sure
Re: Post Your Vb6 Or Vb.net Problems Here by masterd1(m): 5:39pm On Apr 23, 2007
thanx for the tip IG
Re: Post Your Vb6 Or Vb.net Problems Here by Dynast(m): 4:36pm On May 04, 2007
@ Dejisys


can u give some hints to my matrices quest
Re: Post Your Vb6 Or Vb.net Problems Here by rookie(m): 6:53pm On May 04, 2007
@ Charliecode

Thanks for the tip!

(1) (Reply)

Things I Wish Someone Had Told Me When I Was Learning How To Code / Javapos Documentation / 13 Best Techniques To Earn Money As A Web Developer In 2021

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 25
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.