Monday, March 23, 2009

ASP page with database handling

ASP page with database handling

Here is an Sample Example Which Handles MYSQL 5.0 DataBase with .Net

[code]
<%
//This page will be refreshed with each access!
Response.Expires=-1
%>


<%
//create connection object
set con=server.createobject("adodb.connection")
//Conection String and open the connection
call con.open("provider=msdasql;driver={Mysql};server=mysqlServerName;uid=username;pwd=password;database=dbnsme;")
//For Select Query Execution
set rs=con.execute("select * from tablename )
//displaying the records in a table format
//loop till rs has records
while not rs.eof
response.write("<tr><td>" & rs.fields(0) & "</td><td>" & rs.fields(1) & "</td></tr>")
rs.movenext
wend
rs.close()
response.write("</table>")


//Update Process


//update query
//a will contain how mny records are modified
con.execute("Upadte Query goes here"),a
response.write(a & " records updated")
//response.write("Done")



//Insert Process


//insert query
con.execute("insert into RegClLog (SrNo,ProdKey,ClDtTm) values('"& request.form("hidSrno") &"','"& request.form("hidResult") &"','"& request.form("hidClDtTym") &"') "),a
response.write(a & " records Inserted")

//close connection
con.Close()
%>

<html>
<head></head>
<body>
<form action="#" method="post">
Any HTML CODE here will run perfectly. to display the page

</form>
</body>
</html>


//Trapping Errors in ASP.
//This will get the last error occurred.
<%
dim objErr
set objErr=Server.GetLastError()
response.write("ASPCode=" & objErr.ASPCode)
response.write("
")
response.write("ASPDescription=" & objErr.ASPDescription)
response.write("
")
response.write("Category=" & objErr.Category)
response.write("
")
response.write("Column=" & objErr.Column)
response.write("
")
response.write("Description=" & objErr.Description)
response.write("
")
response.write("File=" & objErr.File)
response.write("
")
response.write("Line=" & objErr.Line)
response.write("
")
response.write("Number=" & objErr.Number)
response.write("
")
response.write("Source=" & objErr.Source)
%>

[/code]


Thanks and Regards
Meetu Choudhary
Founder: http://www.msdotnetmentor.com

Keycodes at a glance

While working in the real time development environment some times we feel a great need to know the key codes by which a character is represented. as the computer does not understands the graphical representation but using the keycodes and keyascii we can trace the character used by the user so here is the list for your use. keeping in mind the windows operation system.

Key Code

0 
1 
2 
3 
4 
5 
6 
7 
8 * *
9 * *
10 * *
11 
12 
13 * *
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 [space]
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )
42 *
43 +
44 ,
45 -
46 .
47 /
48 0
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
58 :
59 ;
60 <
61 =
62 >
63 ?
64 @
65 A
66 B
67 C
68 D
69 E
70 F
71 G
72 H
73 I
74 J
75 K
76 L
77 M
78 N
79 O
80 P
81 Q
82 R
83 S
84 T
85 U
86 V
87 W
88 X
89 Y
90 Z
91 [
92 \
93 ]
94 ^
95 _
96 `
97 a
98 b
99 c
100 d
101 e
102 f
103 g
104 h
105 i
106 j
107 k
108 l
109 m
110 n
111 o
112 p
113 q
114 r
115 s
116 t
117 u
118 v
119 w
120 x
121 y
122 z
123 {
124 |
125 }
126 ~
127 
128 €
129 
130 ‚
131 ƒ
132 "
133 …
134 †
135 ‡
136 ˆ
137 ‰
138 Š
139 ‹
140 Œ
141 
142 Ž
143 
144 
145 '
146 '
147 "
148 "
149 o
150 -
151 -
152 ˜
153 ™
154 š
155 ›
156 œ
157 
158 ž
159 Ÿ
160 [space]
161 ¡
162 ¢
163 £
164 ¤
165 ¥
166 ¦
167 §
168 ¨
169 ©
170 ª
171 "
172
173 *
174 ®
175 ¯
176 °
177 ±
178 ²
179 ³
180 ´
181 µ
182
183 ·
184 ¸
185 ¹
186 º
187 "
188 ¼
189 ½
190 ¾
191 ¿
192 À
193 Á
194 Â
195 Ã
196 Ä
197 Å
198 Æ
199 Ç
200 È
201 É
202 Ê
203 Ë
204 Ì
205 Í
206 Î
207 Ï
208 Ð
209 Ñ
210 Ò
211 Ó
212 Ô
213 Õ
214 Ö
215 ×
216 Ø
217 Ù
218 Ú
219 Û
220 Ü
221 Ý
222 Þ
223 ß
224 à
225 á
226 â
227 ã
228 ä
229 å
230 æ
231 ç
232 è
233 é
234 ê
235 ë
236 ì
237 í
238 î
239 ï
240 ð
241 ñ
242 ò
243 ó
244 ô
245 õ
246 ö
247 ÷
248 ø
249 ù
250 ú
251 û
252 ü
253 ý
254 þ
255 ÿ

The Symbol :  represents those characters which are not supported by Microsoft Windows.

The Values 8, 9, 10, and 13 are converted into backspace, tab, linefeed, and carriage return characters, respectively.
They can not be graphically represented but, depending on the application, they can affect the visual display of text.

The values in the table are the Windows default.
where as, values in the ANSI character set above 127 are determined by the code page which is specific to the operating system.

++
Thanks and Regards
Meetu Choudhary
Founder: http://www.msdotnetmentor.com

Saturday, March 14, 2009

JavaScript String Replace All

JavaScript String Replace All

Today When I was working I came across the need to replace all the “’” marks with null or with nothing like “” as the “’” mark produces an error while handling with database I have the StringBuldier Class and could replace all at once but to use that it will be a server side code that means irrespective of anything on textchanged event the page should be postback so I decided to use the JavaScript function replace ()

Now the problem with this JavaScript String Replace function is that it replaces the first occurrence in the string. It takes two simple parameters. The first parameter is the pattern to find and the second parameter is the string to replace the pattern with when found. The JavaScript function does not Replace All...







[code]

str=”http://www.msdotnetheaven.com and http://www.msdotnetheaven.com”;

str = str.replace(/heaven/,”mentor”)



[/code]



The output



str=”http://www.msdotnetmentor.com and http://www.msdotnetheaven.com”;







To make the replace function of the JavaScript to replace all the occurrences of the matched string we have to apply a trick and the trick is, use the g modifier like this:



[code]

str=”http://www.msdotnetheaven.com and http://www.msdotnetheaven.com”;

str = str.replace(/heaven/g,”mentor”)





[/code]







The output



str=”http://www.msdotnetmentor.com and http://www.msdotnetmentor.com”;

Friday, March 13, 2009

Type Text in Upper Case using CSS

Type Text in Upper Case using CSS

While working with web application forms. When we create the forms which can be filled online and then printed to submit we came across the need that the particular textbox such as Name or Father’s Name should be filled in capital letters as most of the conventional forms need this. To accomplish this task we can take help of the CSS property by writing a single line code we can lower our most of the extra work and can concentrate on other parts of the code here is a small example to achieve what I have described above. Here we go:

Type Text in Upper Case using CSS

[code]

< head runat="server" >
< title > Upper Case < /title >
< style type="text/css" >
.test
{
text-transform: uppercase;
}
< /style >
< /head >
< body >
< form id="form1" runat="server" >
< div >

< /div >
< asp:TextBox ID="TextBox1" runat="server" CssClass="test" > < /asp:TextBox >
< /form >
< /body >

[/code]


Thanks and Regards
Meetu Choudhary
founder: http://www.msdotnetmentor.com

Subscribe via email

Enter your email address:

Delivered by FeedBurner

MSDotnetMentor

MSDotnetMentor My Website http://msdotnetmentor.com