|
dejisys (m)
|
If you get stuck in vb, post your problems here.
|
|
|
|
|
|
skyhadi16 (m)
|
I want 2 start learning frm scratch can you help me?
|
|
|
|
|
|
skyhadi16 (m)
|
I want 2 start learning frm scratch can you help me?
|
|
|
|
|
|
rookie (m)
|
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)
|
Hello Deji,
This is to say that you're a VIsual Basic expert, right?
|
|
|
|
|
|
IG
|
@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)
|
I figured out the problem a while back.
Thanks, though
|
|
|
|
|
|
beysoft
|
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
|
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.comthanks
|
|
|
|
|
|
luckyCO
|
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)
|
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)
|
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
|
@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 Hey where's dejisys. I thought he's ready to help, that's why he started this topic.
|
|
|
|
|
|
master d (m)
|
how do i connect my access database to my form in visual basics
|
|
|
|
|
|
IG
|
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") 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)
|
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)
|
thanx for the tip IG
|
|
|
|
|
|
Dynast (m)
|
@ Dejisys
can u give some hints to my matrices quest
|
|
|
|
|
|
rookie (m)
|
@ Charliecode
Thanks for the tip!
|
|
|
|
|
|