473,387 Members | 1,592 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,387 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
Nov 20 '05 #1
4 861
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

Nov 20 '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

Nov 20 '05 #3
Cor
Hi Eric,
That is the easiest,

"SELECT * FROM tablenaam"

tablenaam is the name of your SQL table.

That is all.

Cor
Nov 20 '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

Nov 20 '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...
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...
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,...
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: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I have a couple of newbee questions. I have a .aspx page with a couple of TextBoxes and a submit button. Now... When i press the submitbutton i want the data in the TextBoxes to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.