473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Newbee question about SQL and Datagrid

EMW
I've posted serveral times to get an answer, but till now still now
satisfying answers.

Here is my problem:
I have filled a datagrid control with the contents of an Excel sheet.
Over 3500 rows of information.
I used a dataset which I then binded to the control.

That worked.

Now I want to read the (changed) info from the datagrid into a SQL-server
database.
I have had a hard time finding an example that shows me clearly how to do
that.
Most people answered with documents to me, but that didn't make it more
clear.

I think I have to update the dataset with the changed information first, but
how???
Then I think I have to 'write' this dataset to a SQL file, but how???

I hope someone can give me a good and solid example that can teach me on
this stuff...

Thanks,
Eric
Jul 21 '05 #1
4 1174
Cor
Hi EMW,

Does this helps you a little bit.
\\\
Public Shared Sub UpdateDataset(ByVal sqlStr As String, ByVal ds As DataSet)
Dim Conn As New SqlConnection(connString)
Try
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(sqlStr, Conn)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds.GetChanges)
End If
Catch sqlExc As SqlException
MessageBox.Show(sqlExc.ToString, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
Conn.Close()
End Try
End Sub
///
Cor

Jul 21 '05 #2
EMW
Hi Cor,

It helps a little, but I'm still confused of what to put in the
connectionstring, since I want everything to be put in the file, I set the
SQLstr on "SELECT *". but for the rest I'm still in the dark...

Can you please help me some more?

thanks.
Eric

"Cor" <no*@non.com> schreef in bericht
news:uj**************@TK2MSFTNGP09.phx.gbl...
Hi EMW,

Does this helps you a little bit.
\\\
Public Shared Sub UpdateDataset(ByVal sqlStr As String, ByVal ds As DataSet) Dim Conn As New SqlConnection(connString)
Try
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(sqlStr, Conn)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds.GetChanges)
End If
Catch sqlExc As SqlException
MessageBox.Show(sqlExc.ToString, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
Conn.Close()
End Try
End Sub
///
Cor

Jul 21 '05 #3
Cor
Hi Eric,
That is the easiest,

"SELECT * FROM tablenaam"

tablenaam is the name of your SQL table.

That is all.

Cor
Jul 21 '05 #4
jon
You have to create insert statement.

http://www.naptaxes.com/AAJ/
[AllAmericanJobs - Searching jobs from your desktop and automatically
sends resume.]
"EMW" <so*****@microsoft.com> wrote in message news:<3f**********************@dreader2.news.tisca li.nl>...
Hi Cor,

It helps a little, but I'm still confused of what to put in the
connectionstring, since I want everything to be put in the file, I set the
SQLstr on "SELECT *". but for the rest I'm still in the dark...

Can you please help me some more?

thanks.
Eric

"Cor" <no*@non.com> schreef in bericht
news:uj**************@TK2MSFTNGP09.phx.gbl...
Hi EMW,

Does this helps you a little bit.
\\\
Public Shared Sub UpdateDataset(ByVal sqlStr As String, ByVal ds As

DataSet)
Dim Conn As New SqlConnection(connString)
Try
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(sqlStr, Conn)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds.GetChanges)
End If
Catch sqlExc As SqlException
MessageBox.Show(sqlExc.ToString, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
Conn.Close()
End Try
End Sub
///
Cor

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Newbee | last post by:
Hi ! Let's say that this is the folder on the server: /web/firstDir/secondDir/images/image.gif where i have stored my pictures. I have tryed with apsolute and relative paths but i can't display...
2
by: Newbee Adam | last post by:
some said that .NET app can run on any program where rutime exists. What is "runtime" in this sense? will I have to install runtime or .net framework or .NET support on an xp machine for a...
4
by: PerryC | last post by:
All, 1. Do the following codes seem ok? 2. If so, then how do I pull the value of YOE1 and YOE2 into my report? (to do some further calculations) ...
2
by: Martin Hvidberg | last post by:
Dear list I have found a declaration like this: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <math.h> #include "ectemp.h"
9
by: EMW | last post by:
I have created a page in aspx and after a click on a button, a new page should open. How is this possible? I tried it doing it like in vb.NET with opening a new form, but it doesn't work. rg,...
4
by: EMW | last post by:
I've posted serveral times to get an answer, but till now still now satisfying answers. Here is my problem: I have filled a datagrid control with the contents of an Excel sheet. Over 3500...
7
by: Greg P | last post by:
I'm new to VS2005 and want to simply update my data with the dataGridView that was generated when I draged my query from the Data Sources Pane. I think I may need to create a Data Adaptor but I'm...
8
by: ikarias | last post by:
Maybe not the right place to aske this, but a newbee (me) needs help. i trying to input a number into a textbox, so i can make a series of calculations. in the old days of basic i just jused...
2
by: Mel | last post by:
I have a selection box with 3 values. what i need is to pass 3 urls to a function that has a switch statement and based on the selection index goes on one of the tree urls. Question is how do i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.