Home » Archive by category "MS SQL" (Page 2)

Archive for the 'MS SQL' Category

Update counter in lookup table

Code behind Imports System.Web.UI Imports System.Data.Sql Imports System.Data.SqlClient Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ‘acquire the ad id Dim adLookupCS As String = ConfigurationManager.ConnectionStrings + (“My_ConnectionString1”).ToString Dim adLookupConn As New SqlConnection(adLookupCS) Dim adLookupCmd As New SqlCommand(“SELECT * FROM recordLookup;”, adLookupConn) Dim adLookupRdr As SqlDataReader […]

SqlConnection from web config file in code behind

test.aspx.vb Imports System.Data.SqlClient ————————————- Dim connString As String connString = ConfigurationManager.ConnectionStrings(“MyConnectionString1″).ToString Dim conn As New SqlConnection(connString) web.config <connectionstrings> <add name=”MyConnectionString1″ connectionString=”Data Source=MY-SQL-SRV;Initial Catalog=Northwind; Persist Security Info=True; User ID=my_user;Password=my_pwd” providerName=”System.Data.SqlClient” /> </connectionstrings>

Record Update Confirmation Message

DataSource connection string <asp:sqldatasource ID=”MySQLDS” runat=”server” ConnectionString=”< %$ ConnectionStrings:MyConnString %>” UpdateCommand=”UPDATE [MyTablel] SET [DATE_SUBMITTED] = @DATE_SUBMITTED WHERE [RID] = @RID” OnUpdated=”UpdateMessage” > </asp:sqldatasource> VB code in a head section of the page <head> <script runat=”server”> Sub UpdateMessage(ByVal source As Object, ByVal e As SqlDataSourceStatusEventArgs) If e.AffectedRows > 0 Then ‘ Perform any additional processing, ‘ […]