Showing posts with label learn. Show all posts
Showing posts with label learn. Show all posts

Thursday, March 29, 2012

please convert this classic asp to asp.net

would anyone be willing to convert this classic asp/vbscript/ado to asp.net/vb.net/ado.net? I want to learn how to set Session("userId") using the absolute simplest techniques in asp.net. Thanks in advance.


Dim myConnection
Dim myConnectionStr
Dim myRecordSet
Dim mySQL

Set myConnection = Server.CreateObject("ADODB.Connection")
myConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dataStores\webDbs\webLogin.mdb;"
myConnection.Open myConnectionStr

Set myRecordSet = Server.CreateObject("ADODB.RecordSet")
mySQL = "SELECT tblUsers.userId FROM tblUsers WHERE (((tblUsers.emailAddress)='test@dotnet.itags.org.yahoo.com'));"
myRecordSet.Open mySQL, myConnection

If Not myRecordSet.EOF Then
Session("userId") = myRecordSet("userId")
End If

myRecordSet.Close
Set myRecordSet = Nothing
myConnection.Close
Set myConnection = Nothing

NOTE: Moderator fixed <Code> tags...Hi,

instead of a recordset you can use asqldatareader instead.

Alsoview forum 132.

Grz, Kris.


Sub Page_Load(s As Object, e As EventArgs)
lblResult.Text = getUserId()
End Sub

Function getUserId() As String
Dim myConnection As OleDbConnection
Dim myConnectionStr As String
Dim myCommand As OleDbCommand
Dim myDataReader As OleDbDataReader
Dim mySQL As String

myConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Datastores\LCS_Web\BoardElect.mdb;"
myConnection = New OleDbConnection(myConnectionStr)

mySQL = "SELECT tblUsers.userId FROM tblUsers WHERE (((tblUsers.emailAddress)='test@.yahoo.com'));"
myCommand = New OleDbCommand(mySQL, myConnection)
myConnection.Open()
myDataReader = myCommand.ExecuteReader()

myDataReader.Read()
getUserId = myDataReader.GetValue(0)

myDataReader.Close()
myConnection.Close()
End Function

got it from another forum, but thanks
Does this help ?

PopUpWindow 1.1

regards
that's a very nice component you've written, but is there some correlation to the topic at hand?

Please give me Parameter Examples in ASP.net 2

Please some one help me. I'm trying to learn something very very simple and
I just have to see how it's done. If you're using VS2005 or VWD, please
create this very simple asp.net page for me and just past the whole source
code so I can see how it's done. People keep giving little bitsof code here and there saying try this or this and none of it isworking. Please let me see a completed source code for thissimple asp page.

This is all i want to do.
DB = SQL northwind
Table = Customer
Column = Contact Name
One Textbox = textbox1 with default value of "c"

I just want to see how you can pass a variable to the Select using Like
that contains the value in the textbox1.text. The result will show on a
simple GridView. I know I basically have to do it with parameters and I've
read a lot and tried a lot and can not get it to work. This is the Select
from VS2005. Can someone tell me if this is correct? My peramter name is
@dotnet.itags.org.test. The SQLDataSource is fine.

SelectCommand="SELECT [ContactName] FROM [Customers] WHERE ([ContactName]
LIKE '%' + @dotnet.itags.org.test + '%')"

Please please please create this simple aspx and paste the whole source code
so I can see how it's done.

Thanks in advance.

PhilVS2003 I'm afraid, namespace is SampleWebApp. HTML page;

<%@. Page language="c#" Codebehind="NWTest.aspx.cs" AutoEventWireup="false" Inherits="SampleWebApp.NWTest" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML><HEAD><title>NWTest</title><meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta name="vs_defaultClientScript" content="JavaScript"><meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"></HEAD><body><form id="Form1" method="post" runat="server"><asp:TextBox ID="txtText" Runat="server">c</asp:TextBox><p><asp:DataGrid ID="ResultsGrid" AutoGenerateColumns="True" Runat="server" /></p><p><asp:Button ID="cmdSubmit" Runat="server" Text="Search" /></p></form></body></HTML>

Code-behind;

using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace SampleWebApp{/// <summary>/// Summary description for NWTest./// </summary>public class NWTest : System.Web.UI.Page{protected System.Web.UI.WebControls.Button cmdSubmit;protected System.Web.UI.WebControls.DataGrid ResultsGrid;protected System.Web.UI.WebControls.TextBox txtText;private void Page_Load(object sender, System.EventArgs e){if (Page.IsPostBack){// Define our connection stringstring connection = "server=localhost;database=northwind;uid=sa;pwd=;";// Create a connection objectSqlConnection con = new SqlConnection(connection);// Create a command object for our SELECT, passing the connection objectSqlCommand com = new SqlCommand("SELECT [ContactName] FROM [Customers] WHERE [ContactName] LIKE '%' + @.test + '%'", con);// Creat a parameter to hold the value of @.testSqlParameter p = com.Parameters.Add ("@.test", SqlDbType.VarChar, 50);// Give it a valuep.Value = txtText.Text.Trim();// Open the connectioncon.Open();// Get a DataReader from the commandSqlDataReader r = com.ExecuteReader();// Give the DataReader to the DataGrid as a data sourceResultsGrid.DataSource = r;// Bind the DataGrid, causing it to renderResultsGrid.DataBind();// Close the connectioncon.Close();}}#region Web Form Designer generated codeoverride protected void OnInit(EventArgs e){//// CODEGEN: This call is required by the ASP.NET Web Form Designer.//InitializeComponent();base.OnInit(e);}/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){ this.Load += new System.EventHandler(this.Page_Load);}#endregion}}

Thanks, but it didn't work. I'm using VS2005 and the code is giving me all sort of errors.

Can someone out there using VS2005 or VWD please give me this working example. PLLLEEEAAAASSSSEEE and thank you.
Can't you just create a new web page and cut and paste in only the relevant code? I doubt 2.0 is so far different that complete basics no longer work.
There have been some changes to the @.Page directive and <Head> sections in 2005. The "Web Form Designer generated code" doesn't appear in 2005 unless you specify that you don't want partial classes used. I'd do what Aidy suggested and just cut and paste the pertinent sections (the <form> to </form> and page_load event) into a page you've created.

Please give me Parameter Examples in ASP.net 2

Please some one help me. I'm trying to learn something very very simple and
I just have to see how it's done. If you're using VS2005 or VWD, please
create this very simple asp.net page for me and just past the whole source
code so I can see how it's done.
This is all i want to do.
DB = SQL northwind
Table = Customer
Column = Contact Name
One Textbox = textbox1 with default value of "c"
I just want to see how you can pass a variable to the Select using Like
that contains the value in the textbox1.text. The result will show on a
simple GridView. I know I basically have to do it with parameters and I've
read a lot and tried a lot and can not get it to work. This is the Select
from VS2005. Can someone tell me if this is correct? My peramter name is
@dotnet.itags.org.test. The SQLDataSource is fine.
SelectCommand="SELECT [ContactName] FROM [Customers] WHERE ([ContactName]
LIKE '%' + @dotnet.itags.org.test + '%')"
Please please please create this simple aspx and paste the whole source code
so I can see how it's done.
Thanks in advance.
Philthe following will work so long as you place it within the
<asp:SQLDataSource> tags.
<SelectParameters>
<asp:ControlParameter Name="test" ControlID="textbox1"
PropertyName="Text" />
</SelectParameters>
"Phillip Vong" wrote:

> Please some one help me. I'm trying to learn something very very simple a
nd
> I just have to see how it's done. If you're using VS2005 or VWD, please
> create this very simple asp.net page for me and just past the whole source
> code so I can see how it's done.
> This is all i want to do.
> DB = SQL northwind
> Table = Customer
> Column = Contact Name
> One Textbox = textbox1 with default value of "c"
> I just want to see how you can pass a variable to the Select using Like
> that contains the value in the textbox1.text. The result will show on a
> simple GridView. I know I basically have to do it with parameters and I'v
e
> read a lot and tried a lot and can not get it to work. This is the Select
> from VS2005. Can someone tell me if this is correct? My peramter name is
> @.test. The SQLDataSource is fine.
> SelectCommand="SELECT [ContactName] FROM [Customers] WHERE ([ContactName]
> LIKE '%' + @.test + '%')"
> Please please please create this simple aspx and paste the whole source co
de
> so I can see how it's done.
> Thanks in advance.
> Phil
>
>
>
underprocessable

Please give me Parameter Examples in ASP.net 2

Please some one help me. I'm trying to learn something very very simple and
I just have to see how it's done. If you're using VS2005 or VWD, please
create this very simple asp.net page for me and just past the whole source
code so I can see how it's done.

This is all i want to do.
DB = SQL northwind
Table = Customer
Column = Contact Name
One Textbox = textbox1 with default value of "c"

I just want to see how you can pass a variable to the Select using Like
that contains the value in the textbox1.text. The result will show on a
simple GridView. I know I basically have to do it with parameters and I've
read a lot and tried a lot and can not get it to work. This is the Select
from VS2005. Can someone tell me if this is correct? My peramter name is
@dotnet.itags.org.test. The SQLDataSource is fine.

SelectCommand="SELECT [ContactName] FROM [Customers] WHERE ([ContactName]
LIKE '%' + @dotnet.itags.org.test + '%')"

Please please please create this simple aspx and paste the whole source code
so I can see how it's done.

Thanks in advance.

Philthe following will work so long as you place it within the
<asp:SQLDataSource> tags.

<SelectParameters>
<asp:ControlParameter Name="test" ControlID="textbox1"
PropertyName="Text" />
</SelectParameters
"Phillip Vong" wrote:

> Please some one help me. I'm trying to learn something very very simple and
> I just have to see how it's done. If you're using VS2005 or VWD, please
> create this very simple asp.net page for me and just past the whole source
> code so I can see how it's done.
> This is all i want to do.
> DB = SQL northwind
> Table = Customer
> Column = Contact Name
> One Textbox = textbox1 with default value of "c"
> I just want to see how you can pass a variable to the Select using Like
> that contains the value in the textbox1.text. The result will show on a
> simple GridView. I know I basically have to do it with parameters and I've
> read a lot and tried a lot and can not get it to work. This is the Select
> from VS2005. Can someone tell me if this is correct? My peramter name is
> @.test. The SQLDataSource is fine.
> SelectCommand="SELECT [ContactName] FROM [Customers] WHERE ([ContactName]
> LIKE '%' + @.test + '%')"
> Please please please create this simple aspx and paste the whole source code
> so I can see how it's done.
> Thanks in advance.
> Phil
>
>

Friday, March 16, 2012

Please help me to understand COM

Greetings,

I just started to learn ASP.NET. I'm not familiar with Windows programming since I was using LINUX/PHP for a long time.

I have several questions, answers to which can help me better understand ASP.NET.

My first practical task in ASP.NET is to create music manager which I already wrote in PHP. It is a database that hold albums/artists/songs/covers information. There also a class that reads/write id3v1 and id3v2 mp3 tags (http://getid3.org/).

Here is the main problem. I didn't find any class for ASP.NET that could do the same but there is a project named id3lib http://id3lib.sourceforge.net/ which can be used as a COM object. I have never worked with COM before and truly speaking hardly understand how it works.

Question: id3lib project has COM object included to work with id3 tags, how can I use it in ASP.NET? Where can I find tutorials on working with COM?

Any help is greatly appreciated.

Thanks!You can still reference COM components is ASP.NET. Simply reference the COM object along with the EnterpriseServices component, and .NET will use interop to talk to the COM object. It will be a little slower than if it were a regular .NET assembly, but you can still use it.

hope this helps,
sivilian