User2090065235 posted
Hi,
I'm a new in the world of ASP. I would like to ask Your help in my SQLDataSource question. I created SQLDataSource string in the web config :
<connectionStrings>
<add name="MYConnectionString" connectionString="Data Source=Computer/SQLExpress;Initial Catalog=Database1;Integrated Security=True"
Providername ="System.Data.SqlClient" />
</connectionStrings>
How can i use this connection string in my insert ASP website ?
I tried this code :
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Labeldate.Text = DateTime.Now
End Sub
Protected Sub Submit_Click(sender As Object, e As System.EventArgs) Handles Submit.Click
Using Connection As New SqlConnection("MYConnectionString")
Connection.Open()
Dim cmd As New SqlCommand("insert into customers values ('" & txtboxvname.Text & "', '" & txtboxkname.Text & "', '" & txtboxcompname.Text & "', '" & txtboxdate.Text & "')")
cmd.ExecuteNonQuery()
Connection.Close()
End Using
End Sub
End Class
Thanks for Your help !