- Create a new Module for the connection string.
- Create a Public Funtion so you can access it anywhere in your project.
- paste this code.
- Change the Data Source to your computer name/ sqlexpress.
- change the initial catalog to you database name.
- change user id and password if applicable.
Public Function ExecuteQuery(ByVal Query As String) As DataTable
Dim sqlcon As New SqlConnection("Data Source=CHARLON-PC\SQLEXPRESS;Initial Catalog=dbCyclenessTrading;User ID=sa;Password=admin")
Dim sqlda As New SqlDataAdapter(Query, sqlcon)
Dim sqlcb As New SqlCommandBuilder(sqlda)
Dim dt As New DataTable
sqlda.Fill(dt)
Return dt
End Function
0 comments:
Post a Comment