Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2005, 02:16 AM
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to NitinJoshi
Default Linking Values

hello!!!

i'm having the code of data inserting (database "sqlserever")..i'm writing this code in .vb file(creating classes,so can be used in any form)....in that i wrote a class for database connection & for other things..BUT i'm having a problem like...the values that has to be inserted in database..are taken from another aspx form.
so how do i take values form that aspx page & assign to .vb files insert query

[u]HOW DO I LINK THESE VALUES?</u>

Thanku!!
 
Old January 25th, 2005, 06:21 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

You can add properties to your class and pass these values in this properties collection

Regards
Ganesh
 
Old January 25th, 2005, 06:32 AM
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to NitinJoshi
Default

something like this...

public string Name
{
    get{return txtName.Text;}
}
public string Email
{
    get{return txtEmail.Text;}
}
public string Phone
{
    get{return txtPhone.Text;}
}
 
Old January 25th, 2005, 06:55 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes... U can use properties to enter values in the database. U can also pass the values using method signatures.
Like u hav a method:
public function UpdateEmployee(ByVal EmpId,ByVal EmpFName,...)
End function
But if u need to pass values from one form to another form, there are several ways...
So tell me, what exactly you wanna know..

 
Old January 25th, 2005, 07:53 AM
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to NitinJoshi
Default

I'M giving my code with this..

i want is get the values from mypage.aspx page & pass it to insert query in .vb file..like
insert into mytable(name,id) values(textbox1 value & text box2 value) so these text box value..how can i get these values in .vb file..i want these values from my aspx page

thanx!!!!
the follwing code in .vb file is wrong..i'm just checking it!!!


Public Class InsertData
        Inherits System.Web.UI.Page


        Public Function Insert(ByVal email, ByVal fname)
            Dim sqlconn As SqlConnection
            Dim comm As SqlCommand
            Dim sql As String
            sqlconn = New SqlConnection("data source=SHANTASOFTDC;initial catalog=traveldb;password=sa;persist security info=True;user id=sa;")
            sqlconn.Open()
            sql = "INSERT INTO user_profile_info(email,fname)VALUES ('fname',fname)"
            comm = New SqlCommand(sql, sqlconn)
            Return email
            comm.ExecuteNonQuery()
            sqlconn.Close()
        End Function

    End Class
 
Old January 25th, 2005, 07:54 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

NitinJoshi,

Why are you sending me e-mail with technical questions directly? Posting on this forum is the best way to get a quick answer....


Cheers,

Imar
 
Old January 25th, 2005, 08:14 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nitish,
U have a function named "Insert" inside the class InsertData defined in a seperate .VB file, so how do u expect the Request.Form("email") thing goin to work while your textboxes are defined in mypage.aspx?
U have defined a function and u have no return types defined for the function? U also need to modify function signature like...

Function Insert(ByVal FName AS String, ByVal LName As String, ByVal Email As String) As Integer
.....
End Function
U need to create an instance of the 'InsertData' class in the mypage.aspx code-behind. When you r submitting this page, create an instance of the class in the Submit event and access the 'Insert' function like..
Dim myobj As New InsertData
Dim val as Integer
val = myobj.Insert(Request.Form("fname"),Request.Form("l name"),Request.Form("email"))
...
I guess u need to learn a lot before u start using a class man

 
Old January 25th, 2005, 08:36 AM
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to NitinJoshi
Default

Hey man thanx for u r reply!!!
i submitted the little edited code after that..even i told u the code is not proper..i was experimenting on it!!!

Basically i'm new to .NET Tech.. i've started work on it directly...i'm in learning stage...right now i'm working on a project in a firm...so things like this happens...

but any way thank you very very much for u r Reply!!!

 
Old January 25th, 2005, 09:04 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by NitinJoshi
 ...i'm having the code of data inserting (database "sqlserever")..i'm writing this code in .vb file(creating classes,so can be used in any form)....in that i wrote a class for database connection & for other things..
NitinJoshi,
your vb files just interacts with your datasource so there is no need to derive it from System.Web.UI.Page,
you can write your DataAccess layer in a simple class then in your ASP.NET page you can use it(instantiate it and use its desirable functions).

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.





Similar Threads
Thread Thread Starter Forum Replies Last Post
linking anukagni Access 1 March 28th, 2006 08:21 AM
Compiling/Linking nulogix C++ Programming 8 November 9th, 2005 06:46 PM
Linking Tables Con Access VBA 2 September 24th, 2003 04:32 PM
RE: Linking sherr8 SQL Server 2000 2 July 30th, 2003 02:29 PM
Linking sherr8 Access 2 July 30th, 2003 02:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.