Quantcast
Channel: DataSource Controls - SqlDataSource, ObjectDataSource, etc.
Viewing all articles
Browse latest Browse all 956

SQL Data Source

$
0
0

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 !


Viewing all articles
Browse latest Browse all 956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>