Alright so here is what I am trying to do.
I have a form that someone fills out it has a text box as title, and a drop down box that is a category, and then a text area that is for their explanation.
On the back end I am using a stored procedure called sp_store_bkm. When I execute this it works just fine and puts the data that I put in it into the to table below is the Stored procedure code:
ALTER PROCEDURE sp_store_bkm
@.oID nvarchar OUTPUT,
@.oTitle nvarchar(50),
@.oCategory nvarchar(50),
@.obkmtext nvarchar(MAX)
AS BEGIN
INSERT INTO tbl_bkms(Title, Category, bkmtext)
VALUES(@.oTitle, @.oCategory, @.obkmtext)
Set @.oID= SCOPE_IDENTITY()
END
Now on my front end it comes up with an error in the lower left (erros on page). When I click on the error for details it seems like it is coming fromt he connection string. I cant find anything wrong with the connection string. Below is my code for the aspx page.
<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script>
function Submit2_onclick() {
Dim Connection As SqlConnection = "server=localhost;Database=BKM.mdf;integrated security=SSPI;"
connection.Open()
Try
Dim command As SqlCommand = New SqlCommand("sp_store_bkm", connection)
command.CommandType = CommandType.StoredProcedure
Dim oID As New SqlParameter("@.oID", SqlDbType.Int)
oID.Direction = ParameterDirection.Output
command.Parameters.Add(oID)
command.Parameters.Add("@.oTitle", title.text)
command.Parameters.Add("@.oCategory", category.text)
command.Parameters.Add("@.obkmtext", bkmtext.text)
command.ExecuteNonQuery()
Dim sOrderID As String = oID.Value }
</script>
<form method="post">
<table cellpadding="10" style="width: 100%">
<tr>
<td style="width: 100px">
<span style="font-size: 10pt; font-family: Verdana">
Login ID:
<br />
</span>
<asp:LoginName ID="LoginName1" runat="server" Font-Names="Verdana" Font-Size="10pt" ForeColor="Red" />
<span style="font-size: 10pt; font-family: Verdana">
<br />
<br />
Title:<br />
</span>
<input id="title" style="width: 374px" type="text" /><br />
<br />
<span style="font-size: 10pt; font-family: Verdana">
Category:<br />
</span>
<select id="Category" name="D1" size="1" language="javascript" onclick="return Select1_onclick()">
<option selected="selected">Office Applications</option>
<option>VPN</option>
<option>WLAN</option>
</select>
<br />
<span style="font-size: 10pt; font-family: Verdana">
<br />
Your BKM<br />
</span>
<textarea id="bkmtext" style="width: 378px; height: 196px"></textarea><br />
<br />
<input id="Reset1" type="reset" value="reset" />
<input id="Submit2" type="submit" value="submit" language="javascript" onclick="return Submit2_onclick()" /></td>
</tr>
</table>
</form>
</asp:Content>
Please help.
Well I am closer now. I dont get errors on the page, but nothing gets posted into the DB. If there is an easier way to do this let me know. This is the way I was told to do it.
below is the aspx page, the stored procedure is still the same.
<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language=vbscript type="text/vb">
function Submit2_onclick()
Dim Connection;As SqlConnection = 'Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\BKM.mdf;Integrated Security=True;User Instance=True'
connection.Open()
Try
Dim command As SqlCommand = New SqlCommand("sp_store_bkm", connection)
command.CommandType = CommandType.StoredProcedure
Dim oID As New SqlParameter("@.oID", SqlDbType.Int)
oID.Direction = ParameterDirection.Output
command.Parameters.Add(oID)
command.Parameters.Add("@.oTitle", title.text)
command.Parameters.Add("@.oCategory", category.text)
command.Parameters.Add("@.obkmtext", bkmtext.text)
command.ExecuteNonQuery()
Dim sOrderID As String = oID.Value
End function
</script>
<form method="post">
<table cellpadding="10" style="width: 100%">
<tr>
<td style="width: 100px">
<span style="font-size: 10pt; font-family: Verdana">
Login ID:
<br />
</span>
<asp:LoginName ID="LoginName1" runat="server" Font-Names="Verdana" Font-Size="10pt" ForeColor="Red" />
<span style="font-size: 10pt; font-family: Verdana">
<br />
<br />
Title:<br />
</span>
<input id="title" type="text" /><br />
<br />
<span style="font-size: 10pt; font-family: Verdana">
Category:<br />
</span> <select id="category">
<option selected="selected"></option>
<option>VPN</option>
</select>
<br />
<span style="font-size: 10pt; font-family: Verdana">
<br />
Your BKM<br />
</span>
<textarea id="bkmtext" style="width: 589px; height: 179px"></textarea><br />
<input id="Reset1" type="reset" value="reset" />
<input id="Submit2" type="submit" value="submit BKM" language=vbscript /></td>
</tr>
</table>
</form>
</asp:Content>
|||
now I get the error when I click submit that says
line 265
char: 1
Error: Type mismatch: 'Submit2_onclick'
Code: 0
URL: http://localhost:1755/rvosd_website/bkm/default.aspx