473,473 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

connecting & parameterproblems

Hello everyone,
Being complete newbie in asp.net I am trying to make an example which works
with a very simple database.

First I made my project in VS- vb.net, draging an oledbconnection and an
oledbdataadapter from the toolbox into my form.

Everything worked fine on my local computer. I was able to search, update,
delete and insert into my klanten.mdb database.

When I tried then to upload my project to a hostserver, nothing worked
anymore! After some debugging, I found the reason why: the connectionstring
was
still using the original path, leading to a map on my local computer. I
didn't
find a possibility to change that 'static' path in a more 'dynamic' one,
until I deleted the oledbconnection and the oledbdataadapter, and made them
again without the toolbox, i.o.w. I coded the 2 objects in the
default.aspx.vb. file

The connection seems to be fine now.( using server.mappath in the
connectionstring.)

Now I can search a record without difficulties. However, my update, insert
and deletebuttons work only on my local computer,NOT on the hostserver.

So,my questions are: 1)What am I doing wrong (the error-message is to
cryptical for me!), and 2)isn't it possible to make a dynamic path via the
oledbconnection in the toolbar? (maybe via a key in the web.config?)

Thanks in advance!

Dirk

The error-message I get is :

No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one
or more required parameters.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required
parameters.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1662
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
+152
nieuwdatabase.WebForm1.Button2_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\nieuwdatabase\default.aspx.vb:1 46 PATH ON MY LOCAL
COMPUTER!!!!
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292


My code in the default.aspx.vb file is as follows:

Imports System

Imports System.Data

Imports System.Data.OleDb

Imports Microsoft.VisualBasic

Public Class WebForm1

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected WithEvents lblboodschap As System.Web.UI.WebControls.Label

Protected WithEvents Button5 As System.Web.UI.WebControls.Button

Protected WithEvents Button4 As System.Web.UI.WebControls.Button

Protected WithEvents Button3 As System.Web.UI.WebControls.Button

Protected WithEvents Button2 As System.Web.UI.WebControls.Button

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label5 As System.Web.UI.WebControls.Label

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents txtnummer As System.Web.UI.WebControls.TextBox

Protected WithEvents txtnaam As System.Web.UI.WebControls.TextBox

Protected WithEvents txtadres As System.Web.UI.WebControls.TextBox

Protected WithEvents txtwoonplaats As System.Web.UI.WebControls.TextBox

Protected WithEvents txtpostcode As System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Dim conklanten As OleDbConnection

Dim dadklanten As New OleDbDataAdapter

Dim selklanten As IDbCommand

Dim upklanten As IDbCommand

Dim delklanten As IDbCommand

Dim inklanten As IDbCommand

Dim dasklanten As New DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strcon As String

strcon = "PROVIDER=Microsoft.jet.OLEDB.4.0;DATA SOURCE =" &
Server.MapPath("klanten.mdb") & ";"

conklanten = New OleDbConnection(strcon)

selklanten = conklanten.CreateCommand

selklanten.Connection = conklanten

upklanten = conklanten.CreateCommand

upklanten.Connection = conklanten

delklanten = conklanten.CreateCommand

delklanten.Connection = conklanten

inklanten = conklanten.CreateCommand

inklanten.Connection = conklanten

selklanten.CommandText = "Select * from tblklanten" '

selklanten.CommandType = CommandType.Text

dadklanten.SelectCommand = selklanten

upklanten.CommandText = "update tblklanten set adres = ?, naam = ?, nummer =
?, postcode = ?, woonplaats = ? where (nummer =?) and (adres = ? or ? is
Null and adres is null) and (naam =? or ? is null and naam is null) and
(postcode = ? or ? is null and postcode is null) and (woonplaats =? or ? is
null and woonplaats is null)"

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_nummer" ,
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"nummer", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres1" ,
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.CommandType = CommandType.Text

dadklanten.UpdateCommand = upklanten

delklanten.CommandText = "Delete from tblklanten where (nummer =?)"

delklanten.CommandType = CommandType.Text

delklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

dadklanten.DeleteCommand = delklanten

inklanten.CommandText = "insert into tblklanten(adres, naam, nummer,
postcode, woonplaats) values (?, ?, ?, ?, ?)"

inklanten.CommandType = CommandType.Text

inklanten.Connection = Me.conklanten

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

dadklanten.InsertCommand = inklanten

dadklanten.Fill(dasklanten, "tblklanten")

End Sub

Protected Overrides Sub finalize()

dadklanten.Dispose()

MyBase.Finalize()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

subclear(True)

End Sub

Private Sub subclear(ByVal clearnummer As Boolean)

If clearnummer Then txtnummer.Text = ""

txtnaam.Text = ""

txtadres.Text = ""

txtpostcode.Text = ""

txtwoonplaats.Text = ""

lblboodschap.Text = ""

End Sub

Private Function funcontroleoke() As Boolean

If IsNumeric(txtnummer.Text) AndAlso txtnaam.Text.Trim <> "" AndAlso
txtadres.Text.Trim <> "" AndAlso txtpostcode.Text.Trim <> "" AndAlso
txtwoonplaats.Text.Trim <> "" Then

Return True

End If

End Function

Private Function funzoekrij() As Long

funzoekrij = -1

If IsNumeric(txtnummer.Text) Then

Dim wrij As Long

For wrij = 0 To dasklanten.Tables(0).Rows.Count - 1

If dasklanten.Tables(0).Rows(wrij)("nummer") = CLng(txtnummer.Text)
Then

funzoekrij = wrij

End If

Next

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click ' =search

Dim wrij As Long = funzoekrij()

subclear(False)

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

With dasklanten.Tables(0)

txtnaam.Text = .Rows(wrij)("naam").ToString

txtadres.Text = .Rows(wrij)("adres").ToString

txtpostcode.Text = .Rows(wrij)("postcode").ToString

txtwoonplaats.Text = .Rows(wrij)("woonplaats").ToString

End With

End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click 'update

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

With dasklanten.Tables(0)

.Rows(wrij)("naam") = txtnaam.Text

.Rows(wrij)("adres") = txtadres.Text

.Rows(wrij)("postcode") = txtpostcode.Text

.. Rows(wrij)("woonplaats") = txtwoonplaats.Text

End With

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "Wijzigingen doorgevoerd"

End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim wrij As Long = funzoekrij()

If wrij >= 0 Then

lblboodschap.Text = "Nummer Bestaat al"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

Dim newrij As DataRow = dasklanten.Tables("tblklanten").NewRow

newrij("nummer") = txtnummer.Text

newrij("naam") = txtnaam.Text

newrij("adres") = txtadres.Text

newrij("woonplaats") = txtwoonplaats.Text

newrij("postcode") = txtpostcode.Text

dasklanten.Tables(0).Rows.Add(newrij)

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens ingevoerd"

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click 'delete

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Record met dit nr bestaat niet"

Else

dasklanten.Tables("tblklanten").Rows(wrij).Delete( )

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens verwijderd"

End If

End Sub

End Class

Hello everyone,
Being complete newbie in asp.net I am trying to make an example which works
with a very simple database.

First I made my project in VS- vb.net, draging an oledbconnection and an
oledbdataadapter from the toolbox into my form.

Everything worked fine on my local computer. I was able to search, update,
delete and insert into my klanten.mdb database.

When I tried then to upload my project to a hostserver, nothing worked
anymore! After some debugging, I found the reason: the connectionstring was
still using the original path, leading to a map on my local computer. I
didn't
find a possibility to change that 'static' path in a more 'dynamic' one,
until I deleted the oledbconnection and the oledbdataadapter, and made them
again without the toolbox, i.o.w. I coded the 2 objects in the
default.aspx.vb. file

The connection seems to be fine now.( using server.mappath in the
connectionstring.)

Now I can search a record without difficulties. However, my update, insert
and deletebuttons work only on my local computer,NOT on the hostserver.

So,my questions are: 1)What am I doing wrong (the error-message is to
cryptical for me!), and 2)isn't it possible to make a dynamic path via the
oledbconnection in the toolbar? (maybe via a key in the web.config?)

Thanks in advance!

Dirk

The error-message I get is :

No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one
or more required parameters.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required
parameters.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1662
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
+152
nieuwdatabase.WebForm1.Button2_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\nieuwdatabase\default.aspx.vb:1 46
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292


My code in the default.aspx.vb file is as follows:

Imports System

Imports System.Data

Imports System.Data.OleDb

Imports Microsoft.VisualBasic

Public Class WebForm1

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected WithEvents lblboodschap As System.Web.UI.WebControls.Label

Protected WithEvents Button5 As System.Web.UI.WebControls.Button

Protected WithEvents Button4 As System.Web.UI.WebControls.Button

Protected WithEvents Button3 As System.Web.UI.WebControls.Button

Protected WithEvents Button2 As System.Web.UI.WebControls.Button

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label5 As System.Web.UI.WebControls.Label

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents txtnummer As System.Web.UI.WebControls.TextBox

Protected WithEvents txtnaam As System.Web.UI.WebControls.TextBox

Protected WithEvents txtadres As System.Web.UI.WebControls.TextBox

Protected WithEvents txtwoonplaats As System.Web.UI.WebControls.TextBox

Protected WithEvents txtpostcode As System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Dim conklanten As OleDbConnection

Dim dadklanten As New OleDbDataAdapter

Dim selklanten As IDbCommand

Dim upklanten As IDbCommand

Dim delklanten As IDbCommand

Dim inklanten As IDbCommand

Dim dasklanten As New DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strcon As String

strcon = "PROVIDER=Microsoft.jet.OLEDB.4.0;DATA SOURCE =" &
Server.MapPath("klanten.mdb") & ";"

conklanten = New OleDbConnection(strcon)

selklanten = conklanten.CreateCommand

selklanten.Connection = conklanten

upklanten = conklanten.CreateCommand

upklanten.Connection = conklanten

delklanten = conklanten.CreateCommand

delklanten.Connection = conklanten

inklanten = conklanten.CreateCommand

inklanten.Connection = conklanten

selklanten.CommandText = "Select * from tblklanten" '

selklanten.CommandType = CommandType.Text

dadklanten.SelectCommand = selklanten

upklanten.CommandText = "update tblklanten set adres = ?, naam = ?, nummer =
?, postcode = ?, woonplaats = ? where (nummer =?) and (adres = ? or ? is
Null and adres is null) and (naam =? or ? is null and naam is null) and
(postcode = ? or ? is null and postcode is null) and (woonplaats =? or ? is
null and woonplaats is null)"

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_nummer" ,
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"nummer", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres1" ,
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.CommandType = CommandType.Text

dadklanten.UpdateCommand = upklanten

delklanten.CommandText = "Delete from tblklanten where (nummer =?)"

delklanten.CommandType = CommandType.Text

delklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

dadklanten.DeleteCommand = delklanten

inklanten.CommandText = "insert into tblklanten(adres, naam, nummer,
postcode, woonplaats) values (?, ?, ?, ?, ?)"

inklanten.CommandType = CommandType.Text

inklanten.Connection = Me.conklanten

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

dadklanten.InsertCommand = inklanten

dadklanten.Fill(dasklanten, "tblklanten")

End Sub

Protected Overrides Sub finalize()

dadklanten.Dispose()

MyBase.Finalize()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

subclear(True)

End Sub

Private Sub subclear(ByVal clearnummer As Boolean)

If clearnummer Then txtnummer.Text = ""

txtnaam.Text = ""

txtadres.Text = ""

txtpostcode.Text = ""

txtwoonplaats.Text = ""

lblboodschap.Text = ""

End Sub

Private Function funcontroleoke() As Boolean

If IsNumeric(txtnummer.Text) AndAlso txtnaam.Text.Trim <> "" AndAlso
txtadres.Text.Trim <> "" AndAlso txtpostcode.Text.Trim <> "" AndAlso
txtwoonplaats.Text.Trim <> "" Then

Return True

End If

End Function

Private Function funzoekrij() As Long

funzoekrij = -1

If IsNumeric(txtnummer.Text) Then

Dim wrij As Long

For wrij = 0 To dasklanten.Tables(0).Rows.Count - 1

If dasklanten.Tables(0).Rows(wrij)("nummer") = CLng(txtnummer.Text)
Then

funzoekrij = wrij

End If

Next

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click ' =search

Dim wrij As Long = funzoekrij()

subclear(False)

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

With dasklanten.Tables(0)

txtnaam.Text = .Rows(wrij)("naam").ToString

txtadres.Text = .Rows(wrij)("adres").ToString

txtpostcode.Text = .Rows(wrij)("postcode").ToString

txtwoonplaats.Text = .Rows(wrij)("woonplaats").ToString

End With

End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click 'update

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

With dasklanten.Tables(0)

.Rows(wrij)("naam") = txtnaam.Text

.Rows(wrij)("adres") = txtadres.Text

.Rows(wrij)("postcode") = txtpostcode.Text

.. Rows(wrij)("woonplaats") = txtwoonplaats.Text

End With

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "Wijzigingen doorgevoerd"

End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim wrij As Long = funzoekrij()

If wrij >= 0 Then

lblboodschap.Text = "Nummer Bestaat al"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

Dim newrij As DataRow = dasklanten.Tables("tblklanten").NewRow

newrij("nummer") = txtnummer.Text

newrij("naam") = txtnaam.Text

newrij("adres") = txtadres.Text

newrij("woonplaats") = txtwoonplaats.Text

newrij("postcode") = txtpostcode.Text

dasklanten.Tables(0).Rows.Add(newrij)

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens ingevoerd"

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click 'delete

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Record met dit nr bestaat niet"

Else

dasklanten.Tables("tblklanten").Rows(wrij).Delete( )

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens verwijderd"

End If

End Sub

End Class









Dec 3 '05 #1
1 1410
I'll address your problems on a tangent, and not directly. To me, the
drag-drop method of working with data is something that should not be done.
It would be best if you hand-coded your operations, so that you have all
control over what you're doing, in addition to the fact that you will
understand what is going on. Without looking at your code it'll be
difficult to figure out what's happening, but if you could go back and do it
all yourself, in the codebehind, then you'll have a much better chance of
getting your code to work.

ADO.NET Quickstart:
http://samples.gotdotnet.com/quickst...soverview.aspx

HTH
Altaf
--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com
"dirk van waes" <di***********@telenet.be> wrote in message
news:Ui*********************@phobos.telenet-ops.be...
Hello everyone,
Being complete newbie in asp.net I am trying to make an example which
works
with a very simple database.

First I made my project in VS- vb.net, draging an oledbconnection and an
oledbdataadapter from the toolbox into my form.

Everything worked fine on my local computer. I was able to search, update,
delete and insert into my klanten.mdb database.

When I tried then to upload my project to a hostserver, nothing worked
anymore! After some debugging, I found the reason why: the
connectionstring
was
still using the original path, leading to a map on my local computer. I
didn't
find a possibility to change that 'static' path in a more 'dynamic' one,
until I deleted the oledbconnection and the oledbdataadapter, and made
them
again without the toolbox, i.o.w. I coded the 2 objects in the
default.aspx.vb. file

The connection seems to be fine now.( using server.mappath in the
connectionstring.)

Now I can search a record without difficulties. However, my update, insert
and deletebuttons work only on my local computer,NOT on the hostserver.

So,my questions are: 1)What am I doing wrong (the error-message is to
cryptical for me!), and 2)isn't it possible to make a dynamic path via the
oledbconnection in the toolbar? (maybe via a key in the web.config?)

Thanks in advance!

Dirk

The error-message I get is :

No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for
one
or more required parameters.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required
parameters.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1662
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
+152
nieuwdatabase.WebForm1.Button2_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\nieuwdatabase\default.aspx.vb:1 46 PATH ON MY
LOCAL
COMPUTER!!!!
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292


My code in the default.aspx.vb file is as follows:

Imports System

Imports System.Data

Imports System.Data.OleDb

Imports Microsoft.VisualBasic

Public Class WebForm1

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblboodschap As System.Web.UI.WebControls.Label

Protected WithEvents Button5 As System.Web.UI.WebControls.Button

Protected WithEvents Button4 As System.Web.UI.WebControls.Button

Protected WithEvents Button3 As System.Web.UI.WebControls.Button

Protected WithEvents Button2 As System.Web.UI.WebControls.Button

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label5 As System.Web.UI.WebControls.Label

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents txtnummer As System.Web.UI.WebControls.TextBox

Protected WithEvents txtnaam As System.Web.UI.WebControls.TextBox

Protected WithEvents txtadres As System.Web.UI.WebControls.TextBox

Protected WithEvents txtwoonplaats As System.Web.UI.WebControls.TextBox

Protected WithEvents txtpostcode As System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Dim conklanten As OleDbConnection

Dim dadklanten As New OleDbDataAdapter

Dim selklanten As IDbCommand

Dim upklanten As IDbCommand

Dim delklanten As IDbCommand

Dim inklanten As IDbCommand

Dim dasklanten As New DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strcon As String

strcon = "PROVIDER=Microsoft.jet.OLEDB.4.0;DATA SOURCE =" &
Server.MapPath("klanten.mdb") & ";"

conklanten = New OleDbConnection(strcon)

selklanten = conklanten.CreateCommand

selklanten.Connection = conklanten

upklanten = conklanten.CreateCommand

upklanten.Connection = conklanten

delklanten = conklanten.CreateCommand

delklanten.Connection = conklanten

inklanten = conklanten.CreateCommand

inklanten.Connection = conklanten

selklanten.CommandText = "Select * from tblklanten" '

selklanten.CommandType = CommandType.Text

dadklanten.SelectCommand = selklanten

upklanten.CommandText = "update tblklanten set adres = ?, naam = ?, nummer
=
?, postcode = ?, woonplaats = ? where (nummer =?) and (adres = ? or ? is
Null and adres is null) and (naam =? or ? is null and naam is null) and
(postcode = ? or ? is null and postcode is null) and (woonplaats =? or ?
is
null and woonplaats is null)"

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_nummer" ,
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"nummer", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres1" ,
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.CommandType = CommandType.Text

dadklanten.UpdateCommand = upklanten

delklanten.CommandText = "Delete from tblklanten where (nummer =?)"

delklanten.CommandType = CommandType.Text

delklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

dadklanten.DeleteCommand = delklanten

inklanten.CommandText = "insert into tblklanten(adres, naam, nummer,
postcode, woonplaats) values (?, ?, ?, ?, ?)"

inklanten.CommandType = CommandType.Text

inklanten.Connection = Me.conklanten

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

inklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

dadklanten.InsertCommand = inklanten

dadklanten.Fill(dasklanten, "tblklanten")

End Sub

Protected Overrides Sub finalize()

dadklanten.Dispose()

MyBase.Finalize()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

subclear(True)

End Sub

Private Sub subclear(ByVal clearnummer As Boolean)

If clearnummer Then txtnummer.Text = ""

txtnaam.Text = ""

txtadres.Text = ""

txtpostcode.Text = ""

txtwoonplaats.Text = ""

lblboodschap.Text = ""

End Sub

Private Function funcontroleoke() As Boolean

If IsNumeric(txtnummer.Text) AndAlso txtnaam.Text.Trim <> "" AndAlso
txtadres.Text.Trim <> "" AndAlso txtpostcode.Text.Trim <> "" AndAlso
txtwoonplaats.Text.Trim <> "" Then

Return True

End If

End Function

Private Function funzoekrij() As Long

funzoekrij = -1

If IsNumeric(txtnummer.Text) Then

Dim wrij As Long

For wrij = 0 To dasklanten.Tables(0).Rows.Count - 1

If dasklanten.Tables(0).Rows(wrij)("nummer") = CLng(txtnummer.Text)
Then

funzoekrij = wrij

End If

Next

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click ' =search

Dim wrij As Long = funzoekrij()

subclear(False)

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

With dasklanten.Tables(0)

txtnaam.Text = .Rows(wrij)("naam").ToString

txtadres.Text = .Rows(wrij)("adres").ToString

txtpostcode.Text = .Rows(wrij)("postcode").ToString

txtwoonplaats.Text = .Rows(wrij)("woonplaats").ToString

End With

End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click 'update

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

With dasklanten.Tables(0)

.Rows(wrij)("naam") = txtnaam.Text

.Rows(wrij)("adres") = txtadres.Text

.Rows(wrij)("postcode") = txtpostcode.Text

. Rows(wrij)("woonplaats") = txtwoonplaats.Text

End With

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "Wijzigingen doorgevoerd"

End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim wrij As Long = funzoekrij()

If wrij >= 0 Then

lblboodschap.Text = "Nummer Bestaat al"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

Dim newrij As DataRow = dasklanten.Tables("tblklanten").NewRow

newrij("nummer") = txtnummer.Text

newrij("naam") = txtnaam.Text

newrij("adres") = txtadres.Text

newrij("woonplaats") = txtwoonplaats.Text

newrij("postcode") = txtpostcode.Text

dasklanten.Tables(0).Rows.Add(newrij)

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens ingevoerd"

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click 'delete

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Record met dit nr bestaat niet"

Else

dasklanten.Tables("tblklanten").Rows(wrij).Delete( )

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens verwijderd"

End If

End Sub

End Class

Hello everyone,
Being complete newbie in asp.net I am trying to make an example which
works
with a very simple database.

First I made my project in VS- vb.net, draging an oledbconnection and an
oledbdataadapter from the toolbox into my form.

Everything worked fine on my local computer. I was able to search, update,
delete and insert into my klanten.mdb database.

When I tried then to upload my project to a hostserver, nothing worked
anymore! After some debugging, I found the reason: the connectionstring
was
still using the original path, leading to a map on my local computer. I
didn't
find a possibility to change that 'static' path in a more 'dynamic' one,
until I deleted the oledbconnection and the oledbdataadapter, and made
them
again without the toolbox, i.o.w. I coded the 2 objects in the
default.aspx.vb. file

The connection seems to be fine now.( using server.mappath in the
connectionstring.)

Now I can search a record without difficulties. However, my update, insert
and deletebuttons work only on my local computer,NOT on the hostserver.

So,my questions are: 1)What am I doing wrong (the error-message is to
cryptical for me!), and 2)isn't it possible to make a dynamic path via the
oledbconnection in the toolbar? (maybe via a key in the web.config?)

Thanks in advance!

Dirk

The error-message I get is :

No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for
one
or more required parameters.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required
parameters.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1662
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
+152
nieuwdatabase.WebForm1.Button2_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\nieuwdatabase\default.aspx.vb:1 46
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292


My code in the default.aspx.vb file is as follows:

Imports System

Imports System.Data

Imports System.Data.OleDb

Imports Microsoft.VisualBasic

Public Class WebForm1

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblboodschap As System.Web.UI.WebControls.Label

Protected WithEvents Button5 As System.Web.UI.WebControls.Button

Protected WithEvents Button4 As System.Web.UI.WebControls.Button

Protected WithEvents Button3 As System.Web.UI.WebControls.Button

Protected WithEvents Button2 As System.Web.UI.WebControls.Button

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label5 As System.Web.UI.WebControls.Label

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents txtnummer As System.Web.UI.WebControls.TextBox

Protected WithEvents txtnaam As System.Web.UI.WebControls.TextBox

Protected WithEvents txtadres As System.Web.UI.WebControls.TextBox

Protected WithEvents txtwoonplaats As System.Web.UI.WebControls.TextBox

Protected WithEvents txtpostcode As System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Dim conklanten As OleDbConnection

Dim dadklanten As New OleDbDataAdapter

Dim selklanten As IDbCommand

Dim upklanten As IDbCommand

Dim delklanten As IDbCommand

Dim inklanten As IDbCommand

Dim dasklanten As New DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strcon As String

strcon = "PROVIDER=Microsoft.jet.OLEDB.4.0;DATA SOURCE =" &
Server.MapPath("klanten.mdb") & ";"

conklanten = New OleDbConnection(strcon)

selklanten = conklanten.CreateCommand

selklanten.Connection = conklanten

upklanten = conklanten.CreateCommand

upklanten.Connection = conklanten

delklanten = conklanten.CreateCommand

delklanten.Connection = conklanten

inklanten = conklanten.CreateCommand

inklanten.Connection = conklanten

selklanten.CommandText = "Select * from tblklanten" '

selklanten.CommandType = CommandType.Text

dadklanten.SelectCommand = selklanten

upklanten.CommandText = "update tblklanten set adres = ?, naam = ?, nummer
=
?, postcode = ?, woonplaats = ? where (nummer =?) and (adres = ? or ? is
Null and adres is null) and (naam =? or ? is null and naam is null) and
(postcode = ? or ? is null and postcode is null) and (woonplaats =? or ?
is
null and woonplaats is null)"

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

upklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_nummer" ,
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"nummer", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_adres1" ,
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"adres", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_naam1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"naam", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_postcod e1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"postcode", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_woonpla ats1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte),
"woonplaats", System.Data.DataRowVersion.Original, Nothing))

upklanten.CommandType = CommandType.Text

dadklanten.UpdateCommand = upklanten

delklanten.CommandText = "Delete from tblklanten where (nummer =?)"

delklanten.CommandType = CommandType.Text

delklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

dadklanten.DeleteCommand = delklanten

inklanten.CommandText = "insert into tblklanten(adres, naam, nummer,
postcode, woonplaats) values (?, ?, ?, ?, ?)"

inklanten.CommandType = CommandType.Text

inklanten.Connection = Me.conklanten

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("adres",
System.Data.OleDb.OleDbType.VarWChar, 50, "adres"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("naam",
System.Data.OleDb.OleDbType.VarWChar, 50, "naam"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("nummer",
System.Data.OleDb.OleDbType.Integer, 0, "nummer"))

inklanten.Parameters.Add(New System.Data.OleDb.OleDbParameter("postcode",
System.Data.OleDb.OleDbType.VarWChar, 50, "postcode"))

inklanten.Parameters.Add(New
System.Data.OleDb.OleDbParameter("woonplaats",
System.Data.OleDb.OleDbType.VarWChar, 50, "woonplaats"))

dadklanten.InsertCommand = inklanten

dadklanten.Fill(dasklanten, "tblklanten")

End Sub

Protected Overrides Sub finalize()

dadklanten.Dispose()

MyBase.Finalize()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

subclear(True)

End Sub

Private Sub subclear(ByVal clearnummer As Boolean)

If clearnummer Then txtnummer.Text = ""

txtnaam.Text = ""

txtadres.Text = ""

txtpostcode.Text = ""

txtwoonplaats.Text = ""

lblboodschap.Text = ""

End Sub

Private Function funcontroleoke() As Boolean

If IsNumeric(txtnummer.Text) AndAlso txtnaam.Text.Trim <> "" AndAlso
txtadres.Text.Trim <> "" AndAlso txtpostcode.Text.Trim <> "" AndAlso
txtwoonplaats.Text.Trim <> "" Then

Return True

End If

End Function

Private Function funzoekrij() As Long

funzoekrij = -1

If IsNumeric(txtnummer.Text) Then

Dim wrij As Long

For wrij = 0 To dasklanten.Tables(0).Rows.Count - 1

If dasklanten.Tables(0).Rows(wrij)("nummer") = CLng(txtnummer.Text)
Then

funzoekrij = wrij

End If

Next

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click ' =search

Dim wrij As Long = funzoekrij()

subclear(False)

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

With dasklanten.Tables(0)

txtnaam.Text = .Rows(wrij)("naam").ToString

txtadres.Text = .Rows(wrij)("adres").ToString

txtpostcode.Text = .Rows(wrij)("postcode").ToString

txtwoonplaats.Text = .Rows(wrij)("woonplaats").ToString

End With

End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click 'update

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Niet gevonden"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

With dasklanten.Tables(0)

.Rows(wrij)("naam") = txtnaam.Text

.Rows(wrij)("adres") = txtadres.Text

.Rows(wrij)("postcode") = txtpostcode.Text

. Rows(wrij)("woonplaats") = txtwoonplaats.Text

End With

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "Wijzigingen doorgevoerd"

End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim wrij As Long = funzoekrij()

If wrij >= 0 Then

lblboodschap.Text = "Nummer Bestaat al"

Else

If Not funcontroleoke() Then

lblboodschap.Text = "Onvolledig"

Exit Sub

End If

Dim newrij As DataRow = dasklanten.Tables("tblklanten").NewRow

newrij("nummer") = txtnummer.Text

newrij("naam") = txtnaam.Text

newrij("adres") = txtadres.Text

newrij("woonplaats") = txtwoonplaats.Text

newrij("postcode") = txtpostcode.Text

dasklanten.Tables(0).Rows.Add(newrij)

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens ingevoerd"

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click 'delete

Dim wrij As Long = funzoekrij()

If wrij < 0 Then

lblboodschap.Text = "Record met dit nr bestaat niet"

Else

dasklanten.Tables("tblklanten").Rows(wrij).Delete( )

dadklanten.Update(dasklanten, "tblklanten")

subclear(True)

lblboodschap.Text = "gegevens verwijderd"

End If

End Sub

End Class









Dec 3 '05 #2

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

Similar topics

0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
0
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
4
by: TP | last post by:
Hi, This is probably my 7th post of the day. not spamming, just want to get the questions out, so that I can find the answers and post them back or some good soul can help me out. Right now I...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
1
by: machina12 | last post by:
Familiar with linking to sql using php and java. Is it much different with VB? Have a SQL database. Know the UID, PSWD, Server Name & Database What is code format for linking to SQL Database...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.