I try to insert data to my table but the problem is that give me an error in the clause Return Cmd.ExecuteReader:
Open the quotes after the character string ')'
here the code I have in My file MyModule.VB . Public Module MyModule1
Public ServerName As String = "MIRA"
Public dataBaseName As String = "BaseDB"
Public Cn As New SqlConnection("server=" & ServerName & "; initial catalog=" & dataBaseName & " ; integrated security= true")
Public Cmd As New SqlCommand
Public Dr As SqlDataReader
Public Sub OpenCn()
If Cn.State <> ConnectionState.Open Then
Cn.Open()
End If
End Sub
Public Sub CloseCn()
If Cn.State = ConnectionState.Open Then
Cn.Close()
End If
End Sub
'Type r = select w insert updaate delete
Public Function ExecSQL(ByVal sql As String, Optional ByVal type As String = "r")
OpenCn()
Cmd.CommandType = CommandType.Text
Cmd.CommandText = sql
Cmd.Connection = Cn
If type = "r" Then
Return Cmd.ExecuteReader
Else
Return Cmd.ExecuteNonQuery
End If
CloseCn()
End Function
Public Function AddDB(ByVal natureD As String, ByVal codeP As String, ByVal exigence As String, ByVal nomE As String, ByVal Dt As String, ByVal equipe As String, ByVal Dat1 As String, ByVal Suivi As String)
Return ExecSQL("insert into DossierB values('" & natureD & "', '" & codeP & "', '" & exigence & "', '" & nomE & "', '" & Dt & "', '" & equipe & "', '" & Dat1 & "', '" & Suivi & "' )")
End Function
End Sub
HERE THE CODE OF AjoutDB.aspx.vb
Public Class AjoutDB
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim natureD = Request.Form("DropDownList1")
Dim codeP = Request.Form("TextBox2")
Dim exigence = Request.Form("TextBox5")
Dim nomE = Request.Form("TextBox4")
Dim dt = Request.Form("TextBox8")
Dim equipe = Request.Form("TextBox6")
Dim Dat1 = Request.Form("TextBox9")
Dim Suivi = Request.Form("TextBox7")
AddDB(natureD, codeP, exigence, nomE, dt, equipe, Dat1, Suivi)
MsgBox("données inserees")
End Sub
End Class THANKS A LOT