Newbie:Trying to insert InputmyData.Text onto SQL, but it doesn't work.

  • Thread starter Thread starter Marlon Brown
  • Start date Start date
M

Marlon Brown

The one below reads data from a SQL table.
Can I do something like this ?

Dim myWriter As SqlDataWriter
myWriter = myCMD.ExecuteWriter

I just need to insert Input1.Text and Input2.Text and Input3.Text onto
same table than below,
emp_id, lname, hire_date
rows.

Please advise on how I can accomplish such 'insert' records task ?



Imports System.Data
Imports System.Data.SqlClient
Partial Class Default_aspx
Sub btnDefault_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim myURLFalse As String = "DenyRecovery.aspx"
Dim myURLNotAgree As String = "NotAgree.aspx"
Dim myURLTrue As String = "ConfirmRecovery.aspx"
Dim mySQL As String = "Select * From Employee" _
& " WHERE emp_id = '" & TxtBox1.Text _
& "' AND lname = '" & TxtBox2.Text _
& "' AND hire_date = '" & TxtBox3.Text _
& "'"
Dim myCONN As New SqlConnection
myCONN.ConnectionString = "Server=my;Integrated
Security=True;Database=pubs;Persist Security Info=True"
Dim myCMD As New SqlCommand
myCMD.Connection = myCONN
myCMD.CommandText = mySQL
myCONN.Open()
Dim myReader As SqlDataReader
myReader = myCMD.ExecuteReader
Dim bValid As Boolean = myReader.Read
myReader.Close()
myCONN.Close()
If bValid = True And CheckBox1.Checked = True Then
Response.Redirect(myURLTrue)
Else
If CheckBox1.Checked = False Then
Response.Redirect(myURLNotAgree)
End If
Response.Redirect(myURLFalse)
End If
End Sub
 
Marlon,

Where did you find that SqlDataWriter?

For the rest see my answer about the beta newsgroups for version 2005

Cor
 
Back
Top