0% found this document useful (0 votes)
3 views

c# Connection

Uploaded by

B-63 Arun Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

c# Connection

Uploaded by

B-63 Arun Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

-------------connection .

net to sql
server------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using System.Data.SqlClient;
using System.Data;
using System.Data.Odbc;
using System.Net.Mail;

partial class _Default : System.Web.UI.Page


{
protected void Button1_Click(object sender, EventArgs e)
{
string sConnectionString = @"Persist Security Info=false;User
ID=anjaliux;PWD=anjalius;Initial Catalog=shop;Data Source=DESKTOP-LD5FTH3\
sqlexpress;Connect Timeout=900;Max Pool Size=1500;";

string sInsQuery;
string sInsQueryMySQL;

SqlConnection myConn = new SqlConnection();

myConn = new SqlConnection(sConnectionString);

if (myConn.State == ConnectionState.Closed)
myConn.Open();

sInsQuery = "USP_Sample";

SqlCommand MyCmd = new SqlCommand();

MyCmd = new SqlCommand(sInsQuery, myConn);


MyCmd.CommandTimeout = 0;
MyCmd.ExecuteNonQuery();

int i, j;
Array[] RefNo = new Array[2001];

i = 0;
using (SqlDataReader myReader = MyCmd.ExecuteReader())
{
while ((myReader.Read()))
{
// RefNo(i) = myReader(0)
Response.Write(myReader(i));
i = i + 1;
}
}
MyCmd.Dispose();
myConn.Close();
myConn.Dispose();
}
}
-------------------------sp------------
Alter proc usp_sample
As
Begin
Select 'Suresh Testing' As Output
End

DESKTOP-LD5FTH3\sqlexpress
anjaliux
anjalius

Persist Security Info=false;User ID=anjaliux;PWD=anjalius;Initial Catalog=shop;Data


Source=DESKTOP-LD5FTH3\sqlexpress;Connect Timeout=900;Max Pool Size=1500;"

You might also like