Post Your Vb6 Or Vb.net Problems Here

A Member? Please Login  
type your username and password to login
Date: October 12, 2008, 08:43 AM
248966 members and 147540 Topics
Latest Member: cmeks
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Post Your Vb6 Or Vb.net Problems Here
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Post Your Vb6 Or Vb.net Problems Here  (Read 849 views)
dejisys (m)
Post Your Vb6 Or Vb.net Problems Here
« on: October 10, 2006, 11:30 AM »

If you get stuck in vb, post your problems here.
skyhadi16 (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #1 on: October 10, 2006, 05:09 PM »

I want 2 start learning frm scratch can you help me?
skyhadi16 (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #2 on: October 10, 2006, 05:10 PM »

I want 2 start learning frm scratch can you help me?
rookie (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #3 on: October 11, 2006, 06:13 PM »

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")

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

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

    End Sub
Seun (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #4 on: October 15, 2006, 09:04 PM »

Hello Deji,

This is to say that you're a VIsual Basic expert, right?
IG
Re: Post Your Vb6 Or Vb.net Problems Here
« #5 on: April 09, 2007, 04:42 PM »

@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")

        DBds = ds.Copy()
        DBds.AcceptChanges()
        DBAdapter.Update(DBds.Tables("Table1"))
        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.
rookie (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #6 on: April 09, 2007, 06:25 PM »


I figured out the problem a while back.


Thanks, though
beysoft
Re: Post Your Vb6 Or Vb.net Problems Here
« #7 on: April 17, 2007, 05:49 PM »

please i'm a new fellow in vb area
please 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
ogbon
Re: Post Your Vb6 Or Vb.net Problems Here
« #8 on: April 18, 2007, 12:06 PM »

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
luckyCO
Re: Post Your Vb6 Or Vb.net Problems Here
« #9 on: April 19, 2007, 12:18 PM »

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?
carliecode (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #10 on: April 19, 2007, 05:02 PM »

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
Dynast (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #11 on: April 19, 2007, 05:40 PM »

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
IG
Re: Post Your Vb6 Or Vb.net Problems Here
« #12 on: April 19, 2007, 07:20 PM »

@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.
master d (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #13 on: April 20, 2007, 02:52 PM »

how do i connect my access database to my form in visual basics
IG
Re: Post Your Vb6 Or Vb.net Problems Here
« #14 on: April 22, 2007, 04:23 PM »

Quote from: master d on April 20, 2007, 02:52 PM
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

   
Code:
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")

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).



carliecode (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #15 on: April 23, 2007, 09:55 AM »

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 before 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 this issue. if you need more info, mail me at callcarliecode@yahoo.co.uk . i av passed 70-306 with 100% score and I'm writing 70-305 this wk. i av used dotnet 4 about 6yrs. i am so sure
master d (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #16 on: April 23, 2007, 05:39 PM »

thanx for the tip IG
Dynast (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #17 on: May 04, 2007, 04:36 PM »

@ Dejisys


can u give some hints to my matrices quest
rookie (m)
Re: Post Your Vb6 Or Vb.net Problems Here
« #18 on: May 04, 2007, 06:53 PM »

@ Charliecode

Thanks for the tip!

 Packet Sniffing  A Good Java Developer Is Urgently Needed  Who Knows Python?  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.