hi!
I am using a form to insert the data into a database. But i am getting an error again & again.
Here is the code that i've used:
<%@ Page Language="
VB" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
Dim connectionString as String = "server='(local)';user id='sa';password='soumya';database='MatrixOrders;"
Dim MySQL as string = "Insert into schedule (EmployeeId, Department Name, Date, Start Time, Finish Timem, Notes) " & _
"Values (@EmployeeID, @Department Name, @Date, @Start Time, @Finish Time, @Notes)"
Dim MyConn As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)
'Dim MyConn as New SQLConnection(strConn)'
Dim Cmd as New System.Data.SqlClient.SQLCommand(MySQL, MyConn)
With Cmd.Parameters
.Add(New SQLParameter("@EmployeeID", frmTextBox1.text))
.Add(New SQLParameter("@Department Name", frmTextBox2.text))
.Add(New SQLParameter("@Date", frmTextBox3.text))
.Add(New SQLParameter("@Start Time", frmTextBox6.text))
.Add(New System.Data.SqlClient.SQLParameter("@Finish Time", frmTextBox7.text))
.Add(New SQLParameter("@Notes", frmTextBox9.text))
End With
MyConn.Open()
Cmd.ExecuteNonQuery()
'Put your Success statement Here
'Create a label on the page and assign the success statement to the label's text value, like:
'Label1.Text="Your inormation has been successfully received. " & "We will get back to you as soon as possible"
'Remember to Import the SQLClient Namespace also
MyConn.Close()
End Sub
Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
'Employee ID'
End Sub
Sub TextBox2_TextChanged(sender As Object, e As EventArgs)
'Department Name'
End Sub
Sub TextBox6_TextChanged(sender As Object, e As EventArgs)
'Start Time'
End Sub
Sub TextBox7_TextChanged(sender As Object, e As EventArgs)
'Finish Time'
End Sub
Sub TextBox9_TextChanged(sender As Object, e As EventArgs)
'Notes'
End Sub
Sub TextBox3_TextChanged(sender As Object, e As EventArgs)
'Date'
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<h2 align="center">PLEASE FILL UP THE FIELDS GIVEN BELOW !
</h2>
<h2 align="left"> EMPLOYEE ID :
</h2>
<h2 align="center">
<asp:TextBox id="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
</h2>
<h2 align="left"><strong>   ; DEPARTMENT
NAME :</strong>
</h2>
<h2 align="center">
<asp:TextBox id="TextBox2" runat="server" OnTextChanged="TextBox2_TextChanged" Width="265px"></asp:TextBox>
</h2>
<h2 align="left">
</h2>
<h2 align="center">
</h2>
<h2 align="left">
</h2>
<h2 align="center">
</h2>
<h2 align="left"><strong>   ; DATE
:</strong>
</h2>
<p align="center">
<asp:TextBox id="TextBox3" runat="server" OnTextChanged="TextBox3_TextChanged"></asp:TextBox>
</p>
<h2 align="center">
</h2>
<h2 align="left"><strong>   ; </strong><strong>START
TIME :</strong>
</h2>
<h2 align="center">
<asp:TextBox id="TextBox6" runat="server" OnTextChanged="TextBox6_TextChanged" Width="217px"></asp:TextBox>
</h2>
<h2 align="left"><strong>   ; END TIME
:</strong>
</h2>
<h2 align="center">
<asp:TextBox id="TextBox7" runat="server" OnTextChanged="TextBox7_TextChanged" Width="217px"></asp:TextBox>
</h2>
<h2 align="left">
</h2>
<h2 align="center">
</h2>
<h2 align="left"><strong>   ; NOTES
:</strong>
</h2>
<h2 align="center">
<asp:TextBox id="TextBox9" runat="server" OnTextChanged="TextBox9_TextChanged" Width="336px" Height="50px"></asp:TextBox>
</h2>
<h2 align="left">
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Width="127px" n="n" Text="SUBMIT"></asp:Button>
</h2>
<p align="left">
</p>
<p align="left">
<wmx:MxDataGrid id="MxDataGrid1" runat="server"></wmx:MxDataGrid>
</p>
</form>
</body>
</html>
WHAT IS WRONG WITH THIS CODE? Waiting for a reply as soon as possible.
yash