473,378 Members | 1,346 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,378 software developers and data experts.

insert n save n delete a row

hello
i have a sql table address. name varchar,city varchar,street int

.i want to insert ,delete ,save a record on button controls respectively.in C# and VB.NET .

give code :

corresponding stored procedures.
Apr 13 '07 #1
1 972
klaydze
30
hello
i have a sql table address. name varchar,city varchar,street int

.i want to insert ,delete ,save a record on button controls respectively.in C# and VB.NET .

give code :

corresponding stored procedures.
here are some of the lines of code you needed to save,delete insert and save i think is the same.

Dim objConnection As SqlConnection
Dim objDataAdapter As New SqlDataAdapter
Dim objCommand As New SqlCommand

Dim objDataSet As New DataSet
Dim objDataTable As New DataTable

Dim strSelect As String
Dim strInsert As String
Dim i, j As Integer

Try

strSelect = "Select * from "your table" "
strInsert = "Insert Into tbluseraccess (fld1,fld2....) Values('" & txtfld1.Text & "','" & txtfld2.Text & "')"

objConnection = New SqlConnection("Server=localhost; DataBase="YOUR DBASE"; User ID=sa; pwd=")

objDataAdapter.SelectCommand = New SqlCommand(strSelect, objConnection)

objDataAdapter.Fill(objDataSet)

objDataTable = objDataSet.Tables(0)

With objCommand
.Connection = conn
.Connection.Open()
.CommandText = strInsert
.CommandType = CommandType.Text
.ExecuteNonQuery()

.Connection.Close()
End With

ShowGrid()
MsgBox("Record Save")

Catch ex As Exception
MsgBox(ex.ToString)

End Try

that's it. try the delete and update with your own. just base in that code. its also the same.
Apr 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: jn | last post by:
I have a page that shows info from MySQL. It is for an online education site. It uses different classes arranged in a hierarchy. Each lesson is roughly laid out like this: Lesson |-Intro |...
6
by: Karen Middleton | last post by:
In MS Access I can do in one SQL statement a update if exists else a insert. Assuming my source staging table is called - SOURCE and my target table is called - DEST and both of them have the...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
3
by: Bob Bedford | last post by:
hello I'm looking for some functions or objects allowing to select-insert-update-delete from any table in a mysql database without the need to create a new query every time. Example: ...
2
by: Patrick | last post by:
Hi, im trying to first insert a node in the xml file and save it. XmlDocument mDoc = new XmlDocument(); mDoc.Load("struct.xml"); XmlNode singleNode; XmlNode newNode =...
0
by: teddymeu | last post by:
Hi Guys, since I've done nothing but ask questions these last few weeks to get my first application up and running I thought it was about time to share the wealth and help out a newbie like me since...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.