SqlConnection mConnection = new SqlConnection(mConnectionString);
SqlCommand mCommand = new SqlCommand();
try
{
//Update with Web Response
mCommand = new SqlCommand("spi_Error");
mCommand.CommandType = CommandType.StoredProcedure;
mCommand.Parameters.Add(new SqlParameter("@Message", ErrorString));
mCommand.Parameters.Add(new SqlParameter("@RowNumber", ParameterDirection.Output));
//mCommand.Transaction = mTransaction
mConnection.Open();
mCommand.Connection = mConnection;
mCommand.ExecuteNonQuery();
Thursday, 14 July 2011
Wednesday, 1 June 2011
Wednesday, 4 May 2011
Friday, 29 April 2011
Saturday, 23 April 2011
C# File Stream read/wirte
More File Stream Samples
//******************
FileStream file = File.OpenRead("c:\\siraj\\Post_Check\\" + icb_inputfile);
byte[] buffer = new byte[81];
int c = file.Read(buffer, 0, buffer.Length);
while (c > 0)
{
TXTLine = System.Text.ASCIIEncoding.ASCII.GetString(buffer);
switch (TXTLine.Substring(TXTLine.Length - 3, 2))
{
case "SR":
case "PP":
break;
}
c = file.Read(buffer, 0, buffer.Length);
}
file.Close();
//**********************
//Write Ascii Files
strIssuerFileName = "c:\\Siraj\\" + strIssuerFileName;
StreamWriter sw = new StreamWriter(strIssuerFileName);
sw.Write(strFileText.ToString());
sw.Close();
//******************
FileStream file = File.OpenRead("c:\\siraj\\Post_Check\\" + icb_inputfile);
byte[] buffer = new byte[81];
int c = file.Read(buffer, 0, buffer.Length);
while (c > 0)
{
TXTLine = System.Text.ASCIIEncoding.ASCII.GetString(buffer);
switch (TXTLine.Substring(TXTLine.Length - 3, 2))
{
case "SR":
case "PP":
break;
}
c = file.Read(buffer, 0, buffer.Length);
}
file.Close();
//**********************
//Write Ascii Files
strIssuerFileName = "c:\\Siraj\\" + strIssuerFileName;
StreamWriter sw = new StreamWriter(strIssuerFileName);
sw.Write(strFileText.ToString());
sw.Close();
C# Quick Ref
Creating c# class instance using static method
using System;
using System.Collections.Generic;
using System.Text;
namespace OrderFulfellmentServices.Models
{
public class Class1
{
public Class1()
{
}
public static Class1 Instance
{
get
{
return new Class1();
}
}
public string getBestBuddy()
{
return "best buddy";
}
}
}
the caller
public void Callermethod()
{
...
var st = Class1.Instance.getBestBuddy();
}
-----------------------------------
SQLDataReader
Delegates and events
Add data to database using SqlDataAdapter
Bind related tables and display gridview
Subscribe to:
Posts (Atom)