Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Colombo
YEYE 3 in 1 Instant Coffee Mix 50 Sachet
Romeshka
Updated:
Today at 12:16 AM
Colombo
Red Hat Certified System Administrator (RHCSA) - RHEL 10
Sanjeewani95
Updated:
Friday at 7:43 PM
NURSING , CAREGIVER , HOTEL & BEAUTY COURSES
IVA Para Medical Campus
Updated:
Thursday at 9:24 AM
Handmade Character Soft Toys Peppa Pig Family
anil1961
Updated:
Jul 1, 2026
Ad icon
Video Content Creator
pramukag
Updated:
Jun 28, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
ASP.NET weddo ennawada?? Help akak ona
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Snowl" data-source="post: 11191783" data-attributes="member: 374230"><p>මේක Firefox වලට වැඩ කරනවා අනෙක් ඒවාට කොහොමද දන්නේ නෑ</p><p>නමුත් Basic ක්රමය මේකයි පොඩ්ඩක් Edit කරලන්න අනෙක් Browser වලට වැඩ කරන්නේ නැත්නම්.</p><p>මේක use කරන්නේ Windows Media Player එක.නමුත් Windows Media player plugin එක install</p><p>කරන්න ඕනේ.</p><p></p><p>[code]using System;</p><p>using System.Collections.Generic;</p><p>using System.Web;</p><p>using System.Web.UI;</p><p>using System.Web.UI.WebControls;</p><p>using System.Data.SqlClient;</p><p>using System.Text.RegularExpressions;</p><p></p><p>public partial class sound : System.Web.UI.Page</p><p>{</p><p></p><p> String connectionStr = "";</p><p></p><p> protected void Page_Load(object sender, EventArgs e)</p><p> { </p><p> </p><p> }</p><p></p><p> //############ EVENTS ###################################################################</p><p> protected void Retrieve(object sender, EventArgs e)</p><p> {</p><p> loadAllSoundFiles();</p><p> }</p><p></p><p> protected void createDatabase(object sender, EventArgs e)</p><p> {</p><p> proCreateTheDatabase();</p><p> }</p><p></p><p> protected void saveFile(object sender, EventArgs e)</p><p> {</p><p> proUpdateDatabase();</p><p> }</p><p></p><p> protected void audioSelect_Click(object sender, EventArgs e)</p><p> {</p><p> string getSoundFile = allAudioFiles.SelectedValue;</p><p> makeMp3Player(getSoundFile);</p><p> }</p><p> //############################################################################################</p><p></p><p></p><p></p><p> //################## PROCEDURES ##############################################################</p><p> //<---------- Create The Database ------></p><p> public void proCreateTheDatabase()</p><p> {</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "CREATE TABLE sound(soundID INT NOT NULL,soundPath VARCHAR(200) NOT NULL,PRIMARY KEY(soundID))";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand, con);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> cmd.ExecuteNonQuery();</p><p> con.Close();</p><p> Response.Write("<script type='text/javascript'>alert('Database is created by Snowl.!');</script>");</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('There is an error, perhaps you already made it mister.!');</script>");</p><p> }</p><p> }</p><p></p><p> /*//<---------- Upload The File to the Server ------></p><p> public void proUploadFile()</p><p> {</p><p> String filePath = soundUpload.PostedFile.FileName;</p><p> if (!filePath.Equals("") && !filePath.Equals(null))</p><p> {</p><p> String serverPath = Server.MapPath("~/" + filePath.ToString());</p><p> proUpdateDatabase(serverPath);</p><p> soundUpload.PostedFile.SaveAs(serverPath);</p><p> }</p><p> else</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('You must first select a file to upload.! :P');</script>");</p><p> }</p><p> }</p><p> */</p><p> //<---------- Update The Database ------></p><p> public void proUpdateDatabase()</p><p> {</p><p> string filePath = txtFilePath.Text;</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "INSERT INTO sound(soundID,soundPath) VALUES(@soundID,@soundPath)";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand, con);</p><p> int previousID = proGetPreviousId();</p><p> int newId = previousID + 1;</p><p> cmd.Parameters.AddWithValue("@soundID",newId);</p><p> cmd.Parameters.AddWithValue("@soundPath", filePath);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> cmd.ExecuteNonQuery();</p><p> con.Close();</p><p> Response.Write("<script type='text/javascript'>alert('Record is created by Snowl.!');</script>");</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('There is an error in updating the database.');</script>");</p><p> }</p><p> }</p><p></p><p> //<------------ Get previous id's number ---------></p><p> public int proGetPreviousId()</p><p> {</p><p> int takeId = 0;</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "SELECT soundID FROM sound";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand,con);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> SqlDataReader read = cmd.ExecuteReader();</p><p> while(read.Read())</p><p> {</p><p> takeId = int.Parse(read["soundID"].ToString());</p><p> }</p><p> con.Close();</p><p> int lastId = takeId;</p><p> return lastId;</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> return 0; //This means there is NO value so start from the beginning</p><p> }</p><p> }</p><p></p><p> // <---------- Retrieve the Sound file and put it with the mp3 player ----------></p><p> public void makeMp3Player(string soundFileServerPath)</p><p> {</p><p> string fileToBePlayed = soundFileServerPath;</p><p></p><p> string mp3PlayerCommands = "<embed type='application/x-mplayer2'"+</p><p> " width='420' height='45'"+</p><p> " src='" + fileToBePlayed + "' autostart='true'"+</p><p> " loop='false'>"+</p><p> "</embed>";</p><p> mediaDIV.InnerHtml = mp3PlayerCommands;</p><p> }</p><p></p><p> //<--------- Load All sound files to the Listbox ----------------></p><p> public void loadAllSoundFiles()</p><p> {</p><p> allAudioFiles.Items.Clear();//Clear All Previous items from the item List</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "SELECT soundPath FROM sound";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand, con);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> SqlDataReader read = cmd.ExecuteReader();</p><p> while (read.Read())</p><p> {</p><p> allAudioFiles.Items.Add(read["soundPath"].ToString());</p><p> }</p><p> con.Close();</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('There is an error in searching in the database.');</script>");</p><p> }</p><p> }</p><p> //#############################################################################################</p><p></p><p>}[/code]</p></blockquote><p></p>
[QUOTE="Snowl, post: 11191783, member: 374230"] මේක Firefox වලට වැඩ කරනවා අනෙක් ඒවාට කොහොමද දන්නේ නෑ නමුත් Basic ක්රමය මේකයි පොඩ්ඩක් Edit කරලන්න අනෙක් Browser වලට වැඩ කරන්නේ නැත්නම්. මේක use කරන්නේ Windows Media Player එක.නමුත් Windows Media player plugin එක install කරන්න ඕනේ. [code]using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Text.RegularExpressions; public partial class sound : System.Web.UI.Page { String connectionStr = ""; protected void Page_Load(object sender, EventArgs e) { } //############ EVENTS ################################################################### protected void Retrieve(object sender, EventArgs e) { loadAllSoundFiles(); } protected void createDatabase(object sender, EventArgs e) { proCreateTheDatabase(); } protected void saveFile(object sender, EventArgs e) { proUpdateDatabase(); } protected void audioSelect_Click(object sender, EventArgs e) { string getSoundFile = allAudioFiles.SelectedValue; makeMp3Player(getSoundFile); } //############################################################################################ //################## PROCEDURES ############################################################## //<---------- Create The Database ------> public void proCreateTheDatabase() { SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "CREATE TABLE sound(soundID INT NOT NULL,soundPath VARCHAR(200) NOT NULL,PRIMARY KEY(soundID))"; SqlCommand cmd = new SqlCommand(sqlCommand, con); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script type='text/javascript'>alert('Database is created by Snowl.!');</script>"); } catch (Exception error) { Response.Write("<script type='text/javascript'>alert('There is an error, perhaps you already made it mister.!');</script>"); } } /*//<---------- Upload The File to the Server ------> public void proUploadFile() { String filePath = soundUpload.PostedFile.FileName; if (!filePath.Equals("") && !filePath.Equals(null)) { String serverPath = Server.MapPath("~/" + filePath.ToString()); proUpdateDatabase(serverPath); soundUpload.PostedFile.SaveAs(serverPath); } else { Response.Write("<script type='text/javascript'>alert('You must first select a file to upload.! :P');</script>"); } } */ //<---------- Update The Database ------> public void proUpdateDatabase() { string filePath = txtFilePath.Text; SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "INSERT INTO sound(soundID,soundPath) VALUES(@soundID,@soundPath)"; SqlCommand cmd = new SqlCommand(sqlCommand, con); int previousID = proGetPreviousId(); int newId = previousID + 1; cmd.Parameters.AddWithValue("@soundID",newId); cmd.Parameters.AddWithValue("@soundPath", filePath); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script type='text/javascript'>alert('Record is created by Snowl.!');</script>"); } catch (Exception error) { Response.Write("<script type='text/javascript'>alert('There is an error in updating the database.');</script>"); } } //<------------ Get previous id's number ---------> public int proGetPreviousId() { int takeId = 0; SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "SELECT soundID FROM sound"; SqlCommand cmd = new SqlCommand(sqlCommand,con); try { con.Open(); SqlDataReader read = cmd.ExecuteReader(); while(read.Read()) { takeId = int.Parse(read["soundID"].ToString()); } con.Close(); int lastId = takeId; return lastId; } catch (Exception error) { return 0; //This means there is NO value so start from the beginning } } // <---------- Retrieve the Sound file and put it with the mp3 player ----------> public void makeMp3Player(string soundFileServerPath) { string fileToBePlayed = soundFileServerPath; string mp3PlayerCommands = "<embed type='application/x-mplayer2'"+ " width='420' height='45'"+ " src='" + fileToBePlayed + "' autostart='true'"+ " loop='false'>"+ "</embed>"; mediaDIV.InnerHtml = mp3PlayerCommands; } //<--------- Load All sound files to the Listbox ----------------> public void loadAllSoundFiles() { allAudioFiles.Items.Clear();//Clear All Previous items from the item List SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "SELECT soundPath FROM sound"; SqlCommand cmd = new SqlCommand(sqlCommand, con); try { con.Open(); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { allAudioFiles.Items.Add(read["soundPath"].ToString()); } con.Close(); } catch (Exception error) { Response.Write("<script type='text/javascript'>alert('There is an error in searching in the database.');</script>"); } } //############################################################################################# }[/code] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom