Hi.. I'm developing a website for the first time in visual web developer using asp.net and sql sever database. I have designed my pages and master page. I have created my sql server database too. Please could you help me how to connect the database to asp.net master page? Also I have created a webconfig file. I find many code samples, but not sure where to use which code. Please help me with code and also place where and how to use it.

try this one.

Imports Sql.Data.SqlClient

    Public Function MsDataset(ByVal strSQL As String, ByVal strConn As String) As DataSet
        Dim ds As New DataSet
        Dim newStrConn As New SqlConnection(strConn)
        Dim sqlcmd As SqlCommand = New SqlCommand(strSQL, newStrConn)
        Dim ad As SqlDataAdapter = New SqlDataAdapter
        ad.SelectCommand = sqlcmd
        newStrConn.Open()
        ad.Fill(ds, "a")
        newStrConn.Close()
        Return ds
    End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.