Sunday, December 14, 2008

Stored Procudre to Find next 5 records alphabetically

Stored procedure to find next 5 records alphabetically.Like next 5 records with alphabets starting from a will be b,c,d,e,f

----------

Reliable $1 Web Hosting by 3iX
-------------

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
Create PROCEDURE [dbo].[FindNext5RecordsByCharacter]
(
@CityCharacter char(1)
)
AS
BEGIN
declare @alpha varchar(1)
declare @alpha1 varchar(1)
declare @alpha2 varchar(1)
declare @alpha3 varchar(1)
declare @alpha4 varchar(1)
declare @alpha5 varchar(1)
if (@CityCharacter='y' or @CityCharacter='Y')
begin
set @CityCharacter='a'
set @alpha=@CityCharacter
select @alpha1= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha order by CityName desc
--print @alpha1
select @alpha2= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha1 order by CityName desc
--print @alpha2
select @alpha3= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha2 order by CityName desc
--print @alpha3
select @alpha4= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha3 order by CityName desc
--print @alpha4
end
else if(@CityCharacter<>'z' or @CityCharacter<>'Z' )
begin
set @alpha=@CityCharacter
select @alpha1= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha order by CityName desc
--print @alpha1
select @alpha2= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha1 order by CityName desc
--print @alpha2
select @alpha3= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha2 order by CityName desc
--print @alpha3
select @alpha4= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha3 order by CityName desc
--print @alpha4
end
else
begin
set @CityCharacter='a'
set @alpha=@CityCharacter
select @alpha1= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha order by CityName desc
--print @alpha1
select @alpha2= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha1 order by CityName desc
--print @alpha2
select @alpha3= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha2 order by CityName desc
--print @alpha3
select @alpha4= substring(CityName,1,1) from tbl_city where substring(CityName,1,1) > @alpha3 order by CityName desc
--print @alpha4
end

CREATE TABLE #Temp(
CityId int,
CityName char(30) )

INSERT INTO #Temp (CityId, CityName)
SELECT top 1 CityId, CityName
FROM tbl_city where substring(CityName,1,1) >@alpha
INSERT INTO #Temp (CityId, CityName)
SELECT top 1 CityId, CityName
FROM tbl_city where substring(CityName,1,1) >@alpha1
INSERT INTO #Temp (CityId, CityName)
SELECT top 1 CityId, CityName
FROM tbl_city where substring(CityName,1,1) >@alpha2
INSERT INTO #Temp (CityId, CityName)
SELECT top 1 CityId, CityName
FROM tbl_city where substring(CityName,1,1) >@alpha3
INSERT INTO #Temp (CityId, CityName)
SELECT top 1 CityId, CityName
FROM tbl_city where substring(CityName,1,1) >@alpha4
INSERT INTO #Temp (CityId, CityName)
SELECT top 1 CityId, CityName
FROM tbl_city where substring(CityName,1,1) >@alpha5

select * from #temp
drop table #temp
END

Thursday, November 13, 2008

Implementing St George Payment Gateway using asp.net or c#


St.George Internet Payment Gateway
In order to implement internet payment gateway using St George api,using asp.net and c# you require followings things


Reliable $1 Web Hosting by 3iX

1) webpay.dll and Org.Mentalis.Security.dll
2) Client Id from the st george bank
3) digital certificate and its pwd from the bank

then in the pay button click paste the following code

Int32 pay1 = Convert.ToInt32(amount.Text);
if (pay1>=pay)
{
//Set the following values appropriately for your Bank/Service Provider
//String responseURL = "http://www.gwipg.stgeorge.com.au/";
String responseURL = "";

//To avoid processing duplicate payments, for this user, check the
//if ( Session.Contents[ "WEBPAYOBJECT" ] == null )
//{
webpay.client.Webpay w = new webpay.client.Webpay("10000xxx", "e:\\net.pfx", "yourpwd");
Session.Contents["WEBPAYOBJECT"] = w;
responseURL = processPayment(w);
String expdate = mm.SelectedValue + "/" + yy.SelectedValue;
obj.Insert(Convert.ToInt32(Session["MId"]), Convert.ToDecimal(amount.Text), ddlpaymentmethod.SelectedValue, cardName.Text, txtCardData.Text, cvc2.Text, expdate.ToString());
//}
Response.Redirect(responseURL);
}
else
{
lblpayment.Text = "Payment Should be greater than " + pay;
}



use the following function


private String processPayment(webpay.client.Webpay w)
{
System.Random randObj = new System.Random(5325);
w.setServers("www.gwipg.stgeorge.com.au");
w.setPort(3006); //use 3005 for testing
w.setValue("CLIENTID", "10000xxx");

w.setValue("INTERFACE", "CREDITCARD");
w.setValue("TRANSACTIONTYPE", "PURCHASE");
//Set the following values based on user input, or calculations from other parts of
//your application.
//Please consult your service provider's documentation for
//required and optional fields.
w.setValue("CARDHOLDER_NAME", cardName.Text);
w.setValue("CARDDATA", txtCardData.Text);
w.setValue("CARDEXPIRYDATE", mm.SelectedValue + yy.SelectedValue);
w.setValue("CVC2", cvc2.Text);

w.setValue("TOTALAMOUNT", amount.Text);
w.setValue("CLIENTREF", "" + randObj.Next());

//Store the Webpay Object in the session. So it can be retrieved easily by other pages (results/errors, etc)
Session.Contents["WEBPAYOBJECT"] = w;

System.Exception ex = null;
for (int i = 0; i < 2; i++)
{
try
{
w.execute();
ex = null;
break;
}
catch (webpay.client.ConnectException cex)
{
//Log the error, and try again.
ex = cex;
continue;
}
catch (System.Exception ioex)
{
//If a TXNREFERENCE is available, check the status of the transaction.
//The number of times to loop, and the sleep time may vary depending on the
//requirements of your application.
ex = ioex;
w.setValue("TRANSACTIONTYPE", "STATUS");
for (int j = 0; j < 2; j++)
{
try
{
//In case we the connection was dropped part way thru,
//give the transacton time to complete at the back end
System.Threading.Thread.Sleep(1500);
}
catch (Exception e)
{
}
try
{
w.execute();
//If the responsecode is still "IP", then wait and check the status again.
if (w.getValue("RESPONSECODE") != "IP")
{
//We have a result, continue
break;
}
}
catch (System.Exception e)
{
ex = e;
}
}
}
}
if (ex != null)
{
//An exception was encounteded which could not be recovered, possibly
//while attempting to retry or check status. Set the redirect to a
//page/process which can handle error conditions.
Session.Contents["ERROR"] = ex;
return "ErrorPage.aspx";
}
//Processing completed normally - redirect and display the results to the user.
//NOTE: Your applicaton will need also need to inspect the RESPONSECODE parameter and
//store the transaction result somewhere. This should be done here, and not in the
//Result display code, as this code will only execute once, while the display code has the potential
//to be re-executed if the user clicks "Refresh" or attempts to re-process the transaction
//using the "Back" button.
return "ResultsPage.aspx";
}

}
// if you face any problem please feel free to ask

Thursday, October 30, 2008

HTC TOUCH : Reviews and Price

HTC touch is a great smart phone.It has latest windows mobile operating system.It has all the applications like word,ppt,excel,you can send emails.it has a 2 mega pixel camera and a very unique touch flow.1 gb memory card which is expandable upto 4 gb.
Reliable $1 Web Hosting by 3iX

Lots of great features.a must buy phone if you are looking for a cheap smartphone.In india its costs around rs 15k.

Feel free to post your reviews here....

Thursday, October 23, 2008

GoDaddy Reviews:GoDaddy Web Hosting Review

Webmaters,

if you are looking to get hosting from godaddy.com please think twice before getting a web hosting account from them.Their support is very bad...they always say..this is a coding or 3rd party scripting issue and we can not help.I have atleast 3-4 sites and everyone has some problem.If you are taking windows hosting..pls keep in mind they do not provide remote access to sql server.You have to use their sql server web admin which i feel is not good.so....think twice before going with godaddy.

I will recommend using 3ix...they have very cheap hosting..they have $1 web hosting packages and $3 web hosting packages.They have very good support.I have 2 personal sites with them check below

Reliable $1 Web Hosting by 3iX

Tuesday, October 21, 2008

SRS: Sample SRS Templates

1.Background

This document describes the requirements necessary for the Software Project.

2.Scope

Explain what the software product will do

3.Software Requirement Specification
3.1. System scope

list all the features for which specifications must be created, designed, coded and tested as part of the project.>

3.2. Definitions, Acronyms, Abbreviations

The following is a list of commonly used definitions used throughout this document

5. UI Prototype (Optional)

Attach screen shots and explain control flow.

Reliable $1 Web Hosting by 3iX



6. Assumptions and Dependencies

State any known assumptions and dependencies

7. Non-Functional Requirements

7.1. Environmental Requirements

Hardware and Software requirements

7.2. System Performance Requirements

7.3. Security


7.4. Design and Implementation Constraints

7.5. Standards


8. Evisioned Future Enhancements / Open Issues


9. References

10. Annexures

Friday, October 17, 2008

How to change owner of object/Stored Procedure

to change owner of object/Stored Procedure

exec sp_changeobjectowner 'objectname','username'

for example

exec sp_changeobjectowner 'proc_getallrecords','dbo'

Grant Execute Permission to User in Database:Sql Servers

---Stored Procedure to grant execute permission to user on all stored procedures

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spGrantExectoAllStoredProcs] @user sysname

AS
/

SET NOCOUNT ON



DECLARE @CMD1 varchar(8000)

DECLARE @MAXOID int

DECLARE @OwnerName varchar(128)

DECLARE @ObjectName varchar(128)



CREATE TABLE #StoredProcedures

(OID int IDENTITY (1,1),

StoredProcOwner varchar(128) NOT NULL,

StoredProcName varchar(128) NOT NULL)



INSERT INTO #StoredProcedures (StoredProcOwner, StoredProcName)

SELECT u.[Name], o.[Name]

FROM dbo.sysobjects o

INNER JOIN dbo.sysusers u

ON o.uid = u.uid

WHERE o.Type = 'P'

AND o.[Name] NOT LIKE 'dt_%'


SELECT @MAXOID = MAX(OID) FROM #StoredProcedures



WHILE @MAXOID > 0

BEGIN



SELECT @OwnerName = StoredProcOwner,

@ObjectName = StoredProcName

FROM #StoredProcedures

WHERE OID = @MAXOID



SELECT @CMD1 = 'GRANT EXEC ON ' + '[' + @OwnerName + ']' + '.' + '[' + @ObjectName + ']' + ' TO ' + @user


EXEC(@CMD1)



SET @MAXOID = @MAXOID - 1

END



DROP TABLE #StoredProcedures

SET NOCOUNT OFF

Monday, October 13, 2008

code for 301 redirect pages with querystring using asp.net/c#

if you have a page with query string and you want to redirect it using asp.net please check the code below..

string c_absUri = Request.Url.DnsSafeHost;
string c_absPath = Request.Url.AbsolutePath;
//c_absPath = "/test.aspx";

string c_queryString = Request.QueryString.ToString().Length > 0 ? Request.QueryString.ToString() : String.Empty;


if (c_queryString.Contains("sname=")) //where sname is querystring
{

Int32 Countqry = 0;
Int32 qrylength = 0;
qrylength = c_queryString.Length;

Countqry = c_queryString.LastIndexOf("=");
Int32 rem = qrylength - Countqry;


string sname = c_queryString.Substring(Countqry + 1, rem - 1);

sname = sname.Replace("*", "&");
sname = sname.Replace("+", " ");




string newUrl = "http://www.abc.com" + c_absPath;

HttpContext context = HttpContext.Current;
context.Response.Status = "301 Moved Permanently";
context.Response.StatusCode = 301;
context.Response.AddHeader("Location", newUrl);



Response.Redirect(newUrl);
}

Code for 301 Redirect using c#/ASP.NET

if you want to do a 301 permanent redirect using asp.net and c# copy and paste the code in ur global.asax file.

protected void Application_BeginRequest(object sender, EventArgs e)
{
string newpath = "";
string newpath1 = "";


string sOldPath = HttpContext.Current.Request.Url.ToString();
sOldPath =sOldPath.Substring(sOldPath.LastIndexOf("/")+1);
//
if(sOldPath=="Online.aspx")
{
newpath = "http://www.the.com/online-degree.aspx";
HttpApplication app = sender as HttpApplication;

app.Context.Response.RedirectLocation = newpath.ToString();
app.Context.Response.StatusCode = 301;
app.Context.Response.End();

}}

if you have any questions on doing a 301 redirect please let me know.

Monday, September 29, 2008

using sqlparameter and dataset in C#

// using sqlparameter in C#,Dataset with sqlparameters in c#

SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@TypeID", SqlDbType.Int);
param[0].Value = ddlArticleType.SelectedValue;

DataSet ds = new DataSet();
ds = Obj.GetDataSet(strconnect, "Proc_GetActiveTypeID", param);
DdlCategory.DataSource = ds;
DdlCategory.DataTextField = "Categoryname";
DdlCategory.DataValueField = "CategoryId";
DdlCategory.DataBind();
DdlCategory.Items.Insert(0, "Select Category");

'Please rate this if you like it



Top Blogs

Using Sql Parameters :ASP.NET & C#

//How to use sql parameters to fetch records using dataset (C#).
//Sql Parameters with Dataset

public DataSet GetDataSet(string strConnect, string ProcName,Array parameters)
{
//**************************************
//* Purpose: Getting DataSet for the given Procedure if we have to pass parameters
//* Input parameters:
//*strConnect----Connection string
//*ProcName ---StoredProcedures name
//* Returns :
//*Dataset contains data
//* ************************************
string strCommandText = ProcName;
DataSet ds = new DataSet();

SqlConnection objConnect = new SqlConnection(strConnect);

SqlCommand objCommand = new SqlCommand(strCommandText, objConnect);
objCommand.CommandType = CommandType.StoredProcedure;
foreach (SqlParameter param in parameters)
{
objCommand.Parameters.Add(param);
}

objConnect.Open();
SqlDataAdapter objDataAdapter = new SqlDataAdapter();
objDataAdapter.SelectCommand = objCommand;
objDataAdapter.Fill(ds);
objConnect.Close();
return ds;




}

'Please rate this if you like it

How to fetch records from database and write a text file using vbscript

'How to fetch records from database and write a text file using vbscript.
'If you want to get records from database and write to a text file please use the 'following code
'VBSCRIPT CODE TO WRITE A TEXT FILE,Windows Scipt file to backup database. vbs file
Option Explicit

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Configure this script then run from CMD using cscript
'
' Use the constants below to configure the script
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Database server name
Const server = ""

' Use trusted (windows authenitcation) or standard (SQL Server authentication)

Const trusted = FALSE

' Database user name - not needed for trusted connection

Const userId = ""

' Database password - not needed for trusted connection

Const password = ""

' Database

Const dataBase = ""

Const useUnicode = TRUE
' Set the name of the created file
Const fileName = "records.txt"

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DO NOT EDIT BELOW THIS LINE UNLESS YOU WANT TO ENCHANCE/CHANGE
' THE FUNCTIONALLITY OF THE SCRIPT
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Variables used in the script
Dim db,i,connectString,fields,rs

' Userful ADODB constants
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = 1
Const adUseClient = 3
Const adLockBatchOptimistic = 4


If trusted Then
connectString="Provider=SQLNCLI;Server=" & server & ";Database=" & dataBase & ";Trusted_Connection=yes;"
Else
connectString="Provider=SQLNCLI;Server=" & server & ";Database=" & dataBase & ";Uid=" & userId & ";Pwd=" & password & ";"
End If

Set db = CreateObject("ADODB.Connection")
db.Open connectString
db.Execute "USE " + dataBase

DumpDBDataToFile db,fileName,dataBase,useUnicode
WScript.Echo "All done"
WScript.Quit



Public Sub DumpDBDataToFile(ado, fileName, dataBase,useUnicode)
Dim trc
trc=0
Dim fs
' Open the output file and select the chosen format
Set fs = CreateObject("Scripting.FileSystemObject")
Dim ts
If useUnicode Then
Set ts = fs.OpenTextFile(fileName, 2, True,-1)
Else
Set ts = fs.OpenTextFile(fileName, 2, True)
End If

Dim t,tt
Dim rec
Dim c
Dim trigs


ado.Execute "BEGIN TRANSACTION"
'write sql quey\ry here
Set rec = GetDisconRS(ado,"SELECT * from tablename" )
Dim sql
Dim sql1
Dim first
first = True
If Not rec.EOF Then
rec.MoveFirst
While Not rec.EOF
Dim i
If first Then

sql1 = sql1
first = False

End If
sql = sql1
Dim vt
Dim f,col

For i = 0 To rec.fields.count - 1
f = rec.fields(i).value
col = rec.fields(i).name


''''''''''''''check for padding'''''''''''''
if col="ColumnNAme" then
' MsgBox(f)
f=Rpad(f," ",3)
' MsgBox(Rpad("1"," ",3))
end if




'''''end padding''''''''''


vt = varType(f)
If vt = 1 Then
f = "Null"
ElseIf vt = 2 Or vt = 3 Or vt = 4 Or vt = 5 Or vt = 6 Or vt = 14 Then
f = DBEscapeNumber(CStr(f))
ElseIf vt = 11 Then
If vt Then
f = "1"
Else
f = "0"
End If
ElseIf vt = 8 Then
f = DBEscapeString(CStr(f))
ElseIf vt = 7 Then
f = DBEscapeDate(CStr(f))
ElseIf vt = 17 Then
f = "0x" + Right( "0" & Hex(f),2)
ElseIf vt = 8209 Then
f = "0x" + BinToHex(f)
Else
WScript.Echo "Could not reformat", "Table=" & t & " Col=" & rec.fields(i).name & " vt=" & vt
WScript.Quit
End If
If i > 0 Then sql = sql + ","
sql = sql + f
Next
sql = sql
ts.WriteLine sql

trc=trc+1


rec.MoveNext
Wend

End If
rec.Close




ts.Close
End Sub

'''function for padding
Function Rpad (MyValue, MyPadChar, MyPaddedLength)
'MsgBox(string(MyPaddedLength - Len(MyValue), MyPadChar))
Rpad = MyValue & string(MyPaddedLength - Len(MyValue), MyPadChar)
End Function


Function GetDisconRS(ado,sql)
Dim recset
Set recset = CreateObject("ADODB.Recordset")
recset.CursorLocation = adUseClient
recset.CursorType = adOpenStatic
recset.LockType = adLockBatchOptimistic

recset.Open sql, ado, , , adCmdText
Set recset.ActiveConnection = Nothing
Set GetDisconRS = recset
End Function


Function DateLong(myDate)
Dim months
months=Split("january,february,march,april,may,june,july,august,september,october,november,december",",")
DateLong= _
DatePart("D",mydate) & " " & _
months( DatePart("M",myDate)-1) & " " & _
DatePart("YYYY",mydate)
End Function

''
Function DBEscapeDate(myDate)

DBEscapeDate=DBEscapeString(DateLong(myDate))
End Function

Function DBEscapeString(myString)
DBEscapeString="'" & Replace(myString,"'","''") & "'"
End Function

Function DBEscapeNumber(myNumber)
If NOT IsNumeric(myNumber) Then myNumber=0
myNumber=myNumber*1.0
DBEscapeNumber=Replace(myNumber & "","'","''")
End Function



Function BinToHex(data)
Dim ret
Dim l
Dim i
Dim lb
Dim h
Dim d
Dim o
lb = LBound(data) - 1
l = UBound(data) - LBound(data) + 1
ret = String(l * 2, "0")
Redim o(l-1)

For i = 1 To l
d = 255 and ascb(midb(data,i,1))
If d > 15 Then
o(i-1) = Hex(d)
Else
o(i-1) = "0" + Hex(d)
End If
Next
BinToHex = Join(o,"")
End Function

'Please rate this if you like it

Sunday, September 28, 2008

The server response was: sorry, your mail was administratively denied.

If you get this error. here is what you need to do.While sending mail,in the from field use the email address with your domainname say admin@domainname.com.

This problem comes in godaddy shared hosting if you use anyother email address in the from field,user something@domainname.com

if you have any questions please feel to post..

cheers
admin




The message could not be sent to the SMTP server. The transport error code was 0x800ccc6a

Guys,

Getting this error:

"The message could not be sent to the SMTP server. The transport error code was 0x800ccc6a. The server response was 451 See http://pobox.com/~djb/docs/smtplf.html."

This problem is because of Bare LF ie new line feed.

This error comes when you have a multline textbox and while tying in it you press enter.When you press enter it is repalced by "\r\n" in IE and "\n" in mozilla.

just add the following line of code.Lets say you have a string called msg

msg = msg.Replace("\r\n", "
"); //This is to solve this error in IE
msg = msg.Replace("\n", "
"); //This is to solve this error in //Firefox,mozilla

msg = msg.Replace(Environment.NewLine, "
");


If you still have any problems please feel free to post here.


Cheers
admin


Saturday, September 27, 2008

More From Us

Please visit our main site and Blogs

1) Find Things For You
2) Blogs

Monday, May 12, 2008

Merging Word Docs using ASP.NET,C#

Guys if you wana merge word documents thn you can get the code from here

http://www.codeproject.com/KB/office/mswmergecs.aspx

and you will need to download few dll's that you can get from here

http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en

if you need the working code let me know

cheers
Ric

Friday, May 2, 2008

USING GDI TO DYNAMICALLY ADD IMAGE OR TEXT ON IMAGE ASP.NET

Using GDI to dynamically add image or text on another image in asp.net/vb.net

Public Function writeimage()

' 'USING GDI TO DYNAMICALLY ADD TEXT AND IMAGES ON IMAGE
' INCULDE THE FOLLOWING :
' Imports System.Drawing
'Imports System.Drawing.Image
'Imports System.Drawing.Drawing2D
'Imports System.Drawing.Imaging

Dim myBitmap As New Bitmap(Server.MapPath(ViewState("Imagepath").ToString))
Dim myGraphic As Graphics = Graphics.FromImage(myBitmap)

'set the smoothing mode
myGraphic.SmoothingMode = SmoothingMode.AntiAlias

'draw the oval
'myGraphic.DrawArc(New Pen(Color.White, 2), 280, 0, 120, 50, 0, 360)

'draw the text
'Session("Text") = AddText.Text

Dim ds As New DataSet
ds = getdata()
Dim i, j As Integer
j = ds.Tables(0).Rows.Count

Dim drow As DataRow
If ds.Tables(0).Rows.Count > 0 Then
For Each drow In ds.Tables(0).Rows
Dim textcheck As String = drow("Text").ToString
Dim imagecheck = drow("imagename").ToString

If textcheck <> "NA" Then
'adding text to the image
myGraphic.DrawString(drow("Text"), New Font("Helvetica", 20, FontStyle.Bold), SystemBrushes.WindowText, New PointF(drow("PosX"), drow("PosY")))

ElseIf imagecheck <> "NA" Then
'adding image to the image
Session("imagepath1") = "Uploadedimages/" & LTrim(drow("imagename"))
Dim myimage1 As New Bitmap(Server.MapPath(Session("Imagepath1").ToString))
Dim myThumbNail As New Bitmap(myimage1, 60, 60) 'this will craete a thumbnail of the image
myGraphic.DrawImage(myThumbNail, New PointF(drow("PosX"), drow("PosY")))
' myGraphic.DrawImage(
End If
Next

End If



'note: enable these 3 lines and disable the previous if you want to see vertical text in action
'Dim stringFormat As New StringFormat()
'stringFormat.FormatFlags = StringFormatFlags.DirectionVertical
'myGraphic.DrawString("Alima!", New Font("Helvetica", 30, FontStyle.Bold), SystemBrushes.WindowText, New PointF(290, 10), stringFormat)

'set the content type
'======Getting Error=========================
'Response.ContentType = "image/jpg"
'============================

'save to the outputstream
Dim myBitmap1 As New Bitmap(myBitmap)

myBitmap1.Save(Server.MapPath("DemoImages/" & Session.SessionID & ".jpg"))
myGraphic.Dispose()
myBitmap.Dispose()
Dim testpath As String = "Demoimages/" & Session.SessionID & ".jpg"
Session("testpath") = testpath
prodimg.ImageUrl = testpath
BindGrid()
AddText.Visible = True

GridView1.Visible = True
Panel1.Visible = False


End Function

Thursday, May 1, 2008

USING LINQ TO SQL CLASSES ASP.NET 2008

'USING linq TO SQL TO iNSERT AND bIND GRID ASP.NET 2008


' Ist of all add Linq to sql classes by right click on project and add new item
' Then from server explorer Drag and drop the Database you want to use on the dbml

file u ' added

'then create and object of tht class and use the code below to add and bind gridview

check code below:

Dim db As New DataClassesDataContext '

Dim insemp As New emp
insemp.EName = TextBox1.Text
insemp.Salary = Convert.ToInt32(TextBox2.Text)
db.emps.InsertOnSubmit(insemp)
db.SubmitChanges()

Dim q = From c In db.emps Select c.EName, c.Salary Where Salary >= 1000

GridView2.DataSource = q
GridView2.DataBind()

Wednesday, April 30, 2008

Print Gridview Data using Javascript

copy and paste this function into your aspx file and use an anchor tag to call this function.
function Print()
{ var printgrid = document.getElementById('');
printgrid .border = 0; //set no border here var strOldOne=prtContent.innerHTML; var Printpop = window.open('','','letf=100,top=100,width=1000,height=1000,toolbar=0,scrollbars=1,status=0,resizable=1'); Printpop .document.write(printgrid .outerHTML); Printpop .document.close(); Printpop .focus(); Printpop .print(); Printpop .close();}

Welcome Friends

Hi Friends,
This Blog is all about helping ASP.NET/C#/VB.NET developers.You guys can post your problems that you face in coding.I will try to help on those.I will also post some nice examples which will include using GDI,Ajax,Linq and other coding related issues.
Please feel free to use this blog for posting your queries and comments

Cheers
Ric