Thnks; Ok this inserts data into the database i.e., the connection is Fine.
Code:
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Dim strConn As String
strConn = ConfigurationManager.ConnectionStrings("CCMSConnectionString").ConnectionString
Dim conn As New SqlConnection(strConn)
conn.Open()
Dim strSql As String
strSql = "INSERT INTO dbo.TblChangeControlDet (RequestBy, CreatedBy, ChangeType, TechnicalPerson, Req, BusImp,ChangeRaisedDate, PeerRvw) VALUES (@RequestBy, @CreatedBy, @ChangeType, @TechnicalPerson, @Req, @BusImp,@ChangeRaisedDate, @PeerRvw )"
Dim cmd As New SqlCommand(strSql, conn)
With cmd.Parameters
.AddWithValue("@RequestBy", Me.cmbchngreq.Text)
.AddWithValue("@CreatedBy", Me.cmbchngcrt.Text)
.AddWithValue("@ChangeType", Me.cmbchngtyp.Text)
.AddWithValue("@TechnicalPerson", Me.cmbTechname.Text)
.AddWithValue("@Req", Me.txtreq.Text)
.AddWithValue("@BusImp", Me.txtbusimp.Text)
.AddWithValue("@ChangeRaisedDate", Me.txtdate.Text)
.AddWithValue("@PeerRvw", Me.cmbpeername.Text)
End With
cmd.ExecuteNonQuery()
conn.Close()
End Sub
However, the data is incorrect..
RequestBy = -1 (Expected and item selected which are usually names e.g., John Smith etc)
CreatedBy = -1 (Expected and item selected which are usually names e.g., John Smith etc)
ChangeType = -1 (Expected and item selected which are usually natypes e.g websites)
TechnicalPerson = -1 (Expected and item selected which are usually names e.g., John Smith etc)
Req = Empty (eventhough I typed data before clicking the button)
BusImp = Empty (eventhough I typed data before clicking the button)
ChangeRaisedDate = 18/10/12 (this was the Only correct data)
PeerRvw = -1
Why is it behaving like so.
Note:
My first field is set as Please Select set in asp as
Code:
<asp:ListItem Value="-1">Please Select</asp:ListItem>
Please help me.
Secondly when I click submit button it refreshes all the fields, why? Nothing in the click event states so...
Many thanks