'Full source
'Insert, delete and update don't work
Public Class WebForm1
Inherits System.Web.UI.P age
Protected WithEvents Button1 As
System.Web.UI.W ebControls.Butt on
Protected WithEvents Button2 As
System.Web.UI.W ebControls.Butt on
Protected WithEvents Button3 As
System.Web.UI.W ebControls.Butt on
Protected WithEvents Button4 As
System.Web.UI.W ebControls.Butt on
Protected WithEvents Button5 As
System.Web.UI.W ebControls.Butt on
Protected WithEvents TextBox1 As
System.Web.UI.W ebControls.Text Box
Protected WithEvents TextBox2 As
System.Web.UI.W ebControls.Text Box
Protected WithEvents TextBox3 As
System.Web.UI.W ebControls.Text Box
Protected WithEvents DataGrid1 As
System.Web.UI.W ebControls.Data Grid
Dim cnn1 As New OleDb.OleDbConn ection()
Dim dap1 As New OleDb.OleDbData Adapter()
Dim das1 As New System.Data.Dat aSet()
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
Button1.Text = "Select"
Button2.Text = "Delete"
Button3.Text = "Update"
Button4.Text = "Insert"
Button5.Text = "Refresh"
'Tab index property
Button1.TabInde x = 2
TextBox1.TabInd ex = 1
TextBox2.TabInd ex = 3
TextBox3.TabInd ex = 4
Button2.TabInde x = 5
Button3.TabInde x = 6
Button4.TabInde x = 7
Button5.TabInde x = 8
End If
Dim str1 As String = "Provider =
Microsoft.Jet.O LEDB.4.0;"
str1 &= "Data Source = c:\Archivos de
programa\" & "Microsoft Office\Office10
\Samples\Northw ind.mdb"
cnn1.Connection String = str1
'Invoke Refresh to populate grid control
Refresh()
End Sub
Sub Refresh()
Dim cmd1 As New OleDb.OleDbComm and()
With cmd1
.Connection = cnn1
.CommandText = "SELECT * FROM
VBDotNetShipper s"
End With
Dim dap1 As New OleDb.OleDbData Adapter(cmd1)
dap1.Fill(das1, "VBDotNetShippe rs")
DataGrid1.DataS ource = (das1.Tables
("VBDotNetShipp ers"))
DataGrid1.DataB ind()
End Sub
Private Sub Button1_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button1.Click
Dim int1 As Integer
For int1 = 0 To das1.Tables(0). Rows.Count - 1
If das1.Tables(0). Rows(int1)(0) = CInt
(TextBox1.Text) Then
TextBox2.Text = das1.Tables(0). Rows
(int1)(1)
TextBox3.Text = das1.Tables(0). Rows
(int1)(2)
End If
Next
End Sub
Private Sub Button2_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button2.Click
If IsThere(TextBox 1.Text) = False Then
Response.Write( "DELETE exit trap")
Exit Sub
End If
Dim str1 As String = "DELETE FROM
VBDotNetShipper s " & "WHERE ShipperID=" & TextBox1.Text
'Run SQL String
RunSQLString(st r1)
'Clear controls and refresh from Northwind
ClearAllAndRefr esh()
End Sub
Private Sub Button3_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button3.Click
If IsThere(TextBox 1.Text) = False Then
Response.Write( "UPDATE exit trap")
Exit Sub
End If
'Specify update SQL string
Dim str1 As String = "UPDATE
VBDotNetShipper s " & "SET CompanyName='" & TextBox2.Text
& "', " & "Phone='" & TextBox3.Text & "' WHERE
ShipperID=" & TextBox1.Text
'Run SQL string
RunSQLString(st r1)
ClearAllAndRefr esh()
End Sub
Private Sub Button4_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button4.Click
'Specify insert SQL string
Dim str1 As String = "INSERT INTO
VBDotNetShipper s " & "(CompanyNa me, Phone) VALUES('" &
TextBox2.Text & "', '" & TextBox3.Text & "')"
RunSQLString(st r1)
ClearAllAndRefr esh()
End Sub
Private Sub Button5_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button5.Click
'Clear controls and refresh from Northwind
ClearAllAndRefr esh()
End Sub
Function IsThere(ByVal str1) As Boolean
Dim cmd1 As New OleDb.OleDbComm and()
Dim int1 As Integer
'Run SQL statement to determine if ShipperID
'column value exists
With cmd1
.Connection = cnn1
.CommandText = "SELECT * FROM
VBDotNetShipper s " & "WHERE ShipperID=" & str1
cnn1.Open()
int1 = .ExecuteScalar
cnn1.Close()
End With
'Return true if int1 is greater than 0
If int1 > 0 Then Return True
End Function
Sub RunSQLString(By Val str1 As String)
'Instantiate OleDBCommand object
Dim cmd1 As New OleDb.OleDbComm and()
'Assing Connection and CommandText property
'values before invoking the commad
With cmd1
.Connection = cnn1
.CommandText = str1
cnn1.Open()
.ExecuteNonQuer y()
cnn1.Close()
End With
End Sub
Sub ClearAllAndRefr esh()
das1.Clear()
Refresh()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
End Class 1 2553 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon |
last post by:
Hi,
I am having a little problem with my PHP - MySQl code, I have two tables
(shown below) and I am trying populate a template page with data from both.
<disclaimer>Now I would like to say my skills, especially with MySQL are
rudimentary</disclaimer> However my code (link below) fails, the nested
database call does not return any data and this has me stumped. Any help
will be much appreciated.
Many thanks in advance
|
by: Clay Beatty |
last post by:
When you create database diagrams in Enterprise Manager, the details
for constructing those diagrams is saved into the dtproperties table.
This table includes an image field which contains most of the relevant
infomation, in a binary format.
SQL Enterprise manager offers no way to script out those diagrams, so
I have created two Transact SQL components, one User Function and one
User Procedure, which together provide a means to script...
|
by: Bill MacLean |
last post by:
--
Example Schema posted at end of message:
---
For reporting purposes, I need to build a single comma delimited string of
values from the "many" table
of a database.
The easiest way to see what I want is to look at the sample after my
signature.
By the way, this is actually a busines problem, not homework! I just
|
by: Tim Pascoe |
last post by:
I've been trying to get the scripts posted earlier to the group by
Clay Beatty to work properly. Using the three components he posted, I
have managed to get a new SP generated. However, when I paste this
scrip into a new copy of the original database (different name, same
structure as a test), I get an Invalid Object Name for the temp table
#PersistedVariables.
Has anyone run into something like this before? Or used the scripts I...
|
by: DarthMacgyver |
last post by:
Hello,
I recently wrote a survey application. Each question is very similar.
The first questions gives me a problem when there are multiple people
taking the survey (The Database connection Timed out) I am using the
Data Access Application Blocks as ASP.NET (using VB.NET) and SQL 2000.
In there first question there can be up to 27 answers. So I figured
instead of making 27 different trips to the database I woulc just
concatenate my...
| |
by: Jared Evans |
last post by:
I developed a console application that will continually check a message
queue to watch for any incoming data that needs to be inserted into MS
SQL database.
What would be a low-cost method I could use inside this console
application to make sure the MS SQL database is operational before I
perform the insert?
|
by: altergothen |
last post by:
Hi there
I am a newbie to ASP.Net - Please Help!
I am trying to insert the values of my variables into a database.
If I try the following it works perfectly:
string insertQuery = "INSERT into test(name,surname,email) VALUES('Bob',
'Sly', 'bobsly@yahoo.com')";
but instead of inputing the values directly, I want to insert them as
variables like so:
|
by: josh.kuo |
last post by:
Sorry about the subject, I can't think of a better one.
I recently wrote some PHP classes that I think might be of interest to
this group. Since I have been reaping the benefits of reading news
groups for years, I figure it's time for me to contribute a little bit
back, maybe some people out there will find this useful.
* Introduction
This is a "how-to" style article, showing by example how to dynamically
|
by: Jerim79 |
last post by:
I am no PHP programmer. At my current job I made it known that I was no
PHP programmer during the interview. Still they have given me a script
to write with the understanding that it will take me a while (This
information is just for general knowledge as I don't want anyone
thinking I am trying to be dishonest with my intentions. Also, I do not
portray myself as something I am not. I am a beginner.)
Anyway, what the script needs to do is...
|
by: astolpho |
last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output:
D:\original\CaseStudy-2-5\CaseStudy\Day02\exercise>asant database
Buildfile: build.xml
env-user:
prop-user:
set-user:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |