473,508 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compilation error - Parameterized update

Using Asp.net 1.1
Can somebody tell me why the code following gives this error message:

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30456: 'String' is not a member of
'System.Data.OleDb.OleDbType'.

Source Error:
Line 21: Dim TheNotifyDate as string = NotifyDate.Text
Line 22:
Line 23: Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.String)
Line 24:
Line 25: Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")
<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script language= "VB" runat="server">

'Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

Sub btnSendDatabase_OnClick(Source As Object, E As EventArgs)
Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0; " & _

"Data Source=C:\Inetpub\wwwroot\Acc.mdb" )

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")

Dim SQLString AS String
Dim TheEmpName as String = EmpName.Text

Dim TheDateOfAccident as string = DateOfAccident.Text

Dim TheNotifyDate as string = NotifyDate.Text

Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.String)

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")


SQLString = "INSERT INTO Table1(TheEmpName, TheDate,
TheNotifyDate)VALUES(@TheEmpName,@TheDateOfAcciden t,@TheNotifyDate)"

DBCommand = New OleDBCommand(SQLString, DBConnection)

DBCommand.ExecuteNonquery()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

Dim Cmd as New OleDbCommand(SQLString, DBConnection)

With cmd.Parameters:

..Add(New OleDbParameter("@TheEmpName", EmpName.Text))

..Add(New OleDbParameter("@TheDateOfAccident", DateOfAccident.Text))

..Add(New OleDbParameter("@TheNotifyDate", NotifyDate.Text))

end With
DBConnection.Close()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

End Sub

</script>

</head>

<body>

<form id="form1" runat="server">

Employee's Name: <asp:textbox id="EmpName" runat=server columns="45"/>

<asp:textbox id="DateofAccident" runat=server /></asp:textbox>

<font face="Verdana" Size="2">Date Employer Notified <asp:textbox
id="Notifydate" runat=server/>

<asp:Button id="btnSendDatabase" text="Submit"
OnClick="btnSendDatabase_OnClick" runat="server" />
</form>

</body>

</html>




Aug 3 '07 #1
5 1507
Change to

OleDbType.VarChar

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"dancer" <da****@microsoft.comwrote in message
news:OV**************@TK2MSFTNGP03.phx.gbl...
Using Asp.net 1.1
Can somebody tell me why the code following gives this error message:

Compilation Error
Description: An error occurred during the compilation of a resource
required
to service this request. Please review the following specific error
details
and modify your source code appropriately.

Compiler Error Message: BC30456: 'String' is not a member of
'System.Data.OleDb.OleDbType'.

Source Error:
Line 21: Dim TheNotifyDate as string = NotifyDate.Text
Line 22:
Line 23: Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.String)
Line 24:
Line 25: Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")
<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script language= "VB" runat="server">

'Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

Sub btnSendDatabase_OnClick(Source As Object, E As EventArgs)
Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0; " & _

"Data Source=C:\Inetpub\wwwroot\Acc.mdb" )

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")

Dim SQLString AS String
Dim TheEmpName as String = EmpName.Text

Dim TheDateOfAccident as string = DateOfAccident.Text

Dim TheNotifyDate as string = NotifyDate.Text

Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.String)

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")


SQLString = "INSERT INTO Table1(TheEmpName, TheDate,
TheNotifyDate)VALUES(@TheEmpName,@TheDateOfAcciden t,@TheNotifyDate)"

DBCommand = New OleDBCommand(SQLString, DBConnection)

DBCommand.ExecuteNonquery()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

Dim Cmd as New OleDbCommand(SQLString, DBConnection)

With cmd.Parameters:

.Add(New OleDbParameter("@TheEmpName", EmpName.Text))

.Add(New OleDbParameter("@TheDateOfAccident", DateOfAccident.Text))

.Add(New OleDbParameter("@TheNotifyDate", NotifyDate.Text))

end With
DBConnection.Close()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

End Sub

</script>

</head>

<body>

<form id="form1" runat="server">

Employee's Name: <asp:textbox id="EmpName" runat=server columns="45"/>

<asp:textbox id="DateofAccident" runat=server /></asp:textbox>

<font face="Verdana" Size="2">Date Employer Notified <asp:textbox
id="Notifydate" runat=server/>

<asp:Button id="btnSendDatabase" text="Submit"
OnClick="btnSendDatabase_OnClick" runat="server" />
</form>

</body>

</html>






Aug 3 '07 #2
I changed to VarChar, but now I get this message:
No value given for one or more required parameters
Line 32: DBCommand.ExecuteNonquery()

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:%2****************@TK2MSFTNGP05.phx.gbl...
Change to

OleDbType.VarChar

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"dancer" <da****@microsoft.comwrote in message
news:OV**************@TK2MSFTNGP03.phx.gbl...
>Using Asp.net 1.1
Can somebody tell me why the code following gives this error message:

Compilation Error
Description: An error occurred during the compilation of a resource
required
>to service this request. Please review the following specific error
details
>and modify your source code appropriately.

Compiler Error Message: BC30456: 'String' is not a member of
'System.Data.OleDb.OleDbType'.

Source Error:
Line 21: Dim TheNotifyDate as string = NotifyDate.Text
Line 22:
Line 23: Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.String)
Line 24:
Line 25: Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")
<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script language= "VB" runat="server">

'Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

Sub btnSendDatabase_OnClick(Source As Object, E As EventArgs)
Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0; " &
_

"Data Source=C:\Inetpub\wwwroot\Acc.mdb" )

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")

Dim SQLString AS String
Dim TheEmpName as String = EmpName.Text

Dim TheDateOfAccident as string = DateOfAccident.Text

Dim TheNotifyDate as string = NotifyDate.Text

Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.String)

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")


SQLString = "INSERT INTO Table1(TheEmpName, TheDate,
TheNotifyDate)VALUES(@TheEmpName,@TheDateOfAccide nt,@TheNotifyDate)"

DBCommand = New OleDBCommand(SQLString, DBConnection)

DBCommand.ExecuteNonquery()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

Dim Cmd as New OleDbCommand(SQLString, DBConnection)

With cmd.Parameters:

.Add(New OleDbParameter("@TheEmpName", EmpName.Text))

.Add(New OleDbParameter("@TheDateOfAccident", DateOfAccident.Text))

.Add(New OleDbParameter("@TheNotifyDate", NotifyDate.Text))

end With
DBConnection.Close()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

End Sub

</script>

</head>

<body>

<form id="form1" runat="server">

Employee's Name: <asp:textbox id="EmpName" runat=server columns="45"/>

<asp:textbox id="DateofAccident" runat=server /></asp:textbox>

<font face="Verdana" Size="2">Date Employer Notified <asp:textbox
id="Notifydate" runat=server/>

<asp:Button id="btnSendDatabase" text="Submit"
OnClick="btnSendDatabase_OnClick" runat="server" />
</form>

</body>

</html>







Aug 3 '07 #3
On Aug 3, 7:41 pm, "dancer" <dan...@microsoft.comwrote:
I changed to VarChar, but now I get this message:
No value given for one or more required parameters
Line 32: DBCommand.ExecuteNonquery()
Hi dancer,

"No value given for one or more required parameters" says that the
parameterTheEmpName parameter you have initiated has no value.

Dim parameterTheEmpName as OleDbParameter = new
OleDbParameter("@TheEmpName", OleDbType.VarChar)
parameterTheEmpName.Value = "here_is_your_value"

'After that add the parameter to the command object using the
Parameters collection
{yourCommandNameObject}.Parameters.Add(parameterTh eEmpName)

Then look at your code.

You've created the parameterTheEmpName and you don't use it.

Moreover, after that you do

SQLString = "INSERT INTO Table1(TheEmpName, TheDate,
TheNotifyDate)VALUES(@TheEmpName,@TheDateOfAcciden t,@TheNotifyDate)"
DBCommand = New OleDBCommand(SQLString, DBConnection)
DBCommand.ExecuteNonquery()

Where you created a new OleDBCommand, referred to the @TheEmpName
(again with no value) and other parameters and executed that
DBCommand.

After that you created another OleDbCommand, created and attached a
new @TheEmpName (this time with a value as EmpName.Text) and closed
the connection.

What's the logic behind this?

Basically, you should

1) open a connection
2) create a new command
3) attach all parameters
4) execute a command
5) close connection

Aug 4 '07 #4
Thank you, Alexey, for replying.
I just don't know enough to follow you. I had the following code which
worked with no problem.. But I wanted to change to a Parameterized query.
Could you do me the favor of changing my code to that which uses parameters
correctly?
Then I think I will be able to understand. (The Response.Write statements
are just for checking.)
I'll be forever in your debt!!
<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script language= "VB" runat="server">

'Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

Sub btnSendDatabase_OnClick(Source As Object, E As EventArgs)
Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0; " & _

"Data Source=C:\Inetpub\wwwroot\Acc.mdb" )

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")

Dim SQLString AS String
Dim TheEmpName as String = EmpName.Text

Dim TheDateOfAccident as string = DateOfAccident.Text

Dim TheNotifyDate as string = NotifyDate.Text
Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")


SQLString = "INSERT INTO Table1(TheEmpName, TheDateOfAccident,
TheNotifyDate)VALUES('"+TheEmpName+"','"+TheDateOf Accident+"','"+TheNotifyDate+"')"

DBCommand = New OleDBCommand(SQLString, DBConnection)

DBCommand.ExecuteNonquery()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")
DBConnection.Close()

Response.Write("Value of TheEmpName = " & TheEmpName & "<br>")

End Sub

</script>

</head>

<body>

<form id="form1" runat="server">

Employee's Name: <asp:textbox id="EmpName" runat=server columns="45"/>

<asp:textbox id="DateofAccident" runat=server /></asp:textbox>

<font face="Verdana" Size="2">Date Employer Notified <asp:textbox
id="Notifydate" runat=server/>

<asp:Button id="btnSendDatabase" text="Submit"
OnClick="btnSendDatabase_OnClick" runat="server" />
</form>

</body>

</html>




"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
On Aug 3, 7:41 pm, "dancer" <dan...@microsoft.comwrote:
>I changed to VarChar, but now I get this message:
No value given for one or more required parameters
Line 32: DBCommand.ExecuteNonquery()

Hi dancer,

"No value given for one or more required parameters" says that the
parameterTheEmpName parameter you have initiated has no value.
Basically, you should

1) open a connection
2) create a new command
3) attach all parameters
4) execute a command
5) close connection

Aug 5 '07 #5
On Aug 5, 3:55 pm, "dancer" <dan...@microsoft.comwrote:
Thank you, Alexey, for replying.
I just don't know enough to follow you. I had the following code which
worked with no problem.. But I wanted to change to a Parameterized query.
Could you do me the favor of changing my code to that which uses parameters
correctly?
Then I think I will be able to understand. (The Response.Write statements
are just for checking.)
I'll be forever in your debt!!
<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script language= "VB" runat="server">

'Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

Sub btnSendDatabase_OnClick(Source As Object, E As EventArgs)

Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0; " & _

"Data Source=C:\Inetpub\wwwroot\Acc.mdb" )

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")
The code looks correct, except the line with

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")

Change it to "SELECT * FROM table1"

Hope this helps

Aug 6 '07 #6

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

Similar topics

0
6678
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
4
4325
by: Gilberto Campos | last post by:
Hi all. I am having a strange problem. I am developping an application that acceses an Access db through Jet (.UDL files). I have writen parametric INSERT queries that work fine. I am now...
10
9356
by: RedEagle | last post by:
Hi All! Do you remember me? I am that desperate who had this error for a while: --- Compilation Error Description: An error occurred during the compilation of a resource required to service...
1
2081
by: Peter | last post by:
Hi, When I update/add a new web reference to a web service class with a parameterized constructor, what is preventing the generated proxy from including a definition for the parameterized...
8
5302
by: Jess | last post by:
Hi, I have a template function that triggered some compiler error. The abridged version of the class and function is: #include<memory> using namespace std; template <class T>
4
12448
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
For MS SQL Server... I am used to declaring local variables in my SQL queries... Declare @MyInt int, @MyChar varchar(33) Parameters were idenfitied with a colon... Where ModDate :MyDate But,...
3
1443
by: ocmeng | last post by:
Dear All, I am kinda new to Oracle and need to work on a stored proc to update some data. However, I am getting compilation error for the following stored proc and got no idea on how to resolve...
1
1321
by: abhishekgvyas | last post by:
Hi, can somebody tell me what is wrong with the following stored procedure code.. SQL> CREATE OR REPLACE PROCEDURE DEBIT_ACCOUNT(ACCT_ID IN NUMBER, DEBIT_AMOUNT OUT NUMBER) 2 IS 3 ...
5
2993
by: stanman | last post by:
I have been trying to get past this error all day. I am unable to determine why I get syntax error from the following code: //modify a record $myDataID = mysql_query("UPDATE members SET...
0
7231
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
7133
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
7336
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
7405
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
7066
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
7504
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
3214
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
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
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.