CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke.getting_started Tags:
Item Type: NewsGroup Date Entered: 6/13/2004 8:45:28 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 4 Views: 21 Favorited: 0 Favorite
5 Items, 1 Pages 1 |< << Go >> >|
lilryno
Asp.Net User
Plugging holes in a dyke... (datasets and SQL statements) - kinda complicated6/13/2004 8:45:28 PM

0

Not sure if I spelled **** the right way or not. I meant the thing that holds back water. Ok, whatever.

Alright. I got this form with some textboxes on it. I've also got this Access database created to hold the values of these textboxes. My goal...when a registered user to my DNN site goes to the page that has this form (which part of my custom module)...the textboxes will be populated with info from the database (assuming this user has saved info into the database already). Additionally, the user can edit the textboxes and save the changes to the database. The database has the userid (generated by DNN for that user) and several other fields corresponding to the textbox information.

So why plugging holes? Because I have programmed procedures for the page_load and procedures for a the button_click (which is displayed next to the textboxes which says "Click to Save Changes"). So far, depending on how I position a dataset.clear() I can either:

A. Have the page initially load and display the user's saved database info into the textboxes (which I want)

OR

B. Have the button_click succesfully update the contents of the database

But I can't do both. Both functions work...just not at the same time. Which works when? Depends on where I put the dataset.clear() in the page_load. I'm not sure why, though. I've posted the code for both the page_load and the button_click events in the hopes that somebody can point out my errors. Thanks for any help you can provide.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Put in code that first checks to see if this is a registerd user and if so:
' Opens the AircraftProfile.mdb and checks to see if userid exists and if so:
' Loads the user's info and populates the textboxes accordingly

Dim IobjUsers As New UserController
Dim IobjUser As UserInfo
Dim Isregistered As Boolean
Isregistered = True

Try
IobjUser = IobjUsers.GetUser(PortalId, Int32.Parse(context.User.Identity.Name))
' the above works ONLY if it's a registered user...otherwise it returns an error
Catch ex As Exception

Isregistered = False
End Try

If Isregistered Then

Dim IOurUserID As String

If Not IobjUser Is Nothing Then
IOurUserID = IobjUser.UserID.ToString
End If

Dim IAIR_PROdb As New OleDb.OleDbConnection
Dim IGetAIR_PRO As New OleDb.OleDbCommand
Dim IAIR_PROAdapter As New OleDb.OleDbDataAdapter
Dim IAIR_PROds As New DataSet

Try

IAIR_PROdb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSourcePath & "aircraftprofile.mdb"
IGetAIR_PRO.CommandText = "Select * from AIR_PROFILE WHERE user_id='" & IOurUserID & "'"
IGetAIR_PRO.Connection = IAIR_PROdb
IAIR_PROAdapter.SelectCommand = IGetAIR_PRO

IAIR_PROdb.Open()
Catch ex As Exception
SysError = True
ErrorRpt &= "***There was a problem accessing the Aircraft Profile database on Flight Plan page load: " & ex.ToString
End Try

Try

IAIR_PROAdapter.Fill(IAIR_PROds, "AIR_PROFILE")

IAIR_PROdb.Close()

Catch ex As Exception
SysError = True
ErrorRpt &= "***There was a problem filling the dataset from the Aircraft Profile database on Flight Plan page load: " & ex.ToString
End Try

Dim IAIR_PROtable As New DataTable
IAIR_PROtable = IAIR_PROds.Tables("AIR_PROFILE")

If IAIR_PROtable.Rows.Count = 0 Then Return 'cuz no profile saved yet

Textbox19.Text = IAIR_PROtable.Rows(0)(1) 'fill TAS
TextBox7.Text = IAIR_PROtable.Rows(0)(2) 'operating weight
TextBox8.Text = IAIR_PROtable.Rows(0)(3) 'fuel load
Dropdownlist2.SelectedIndex = IAIR_PROtable.Rows(0)(4) 'Aircraft Category
Textbox4.Text = IAIR_PROtable.Rows(0)(5) 'Min Departure Rwy Length
Textbox9.Text = IAIR_PROtable.Rows(0)(6) 'Min Arrival Rwy Length
Textbox5.Text = IAIR_PROtable.Rows(0)(7) 'Min Rwy Width
Textbox6.Text = IAIR_PROtable.Rows(0)(8) 'Max Crosswind
DropDownList1.SelectedIndex = IAIR_PROtable.Rows(0)(9) 'Aircraft Type
Textbox20.Text = IAIR_PROtable.Rows(0)(10) 'Burn Rate

IAIR_PROds.Clear() 'PUT IT HERE-initial load works but won't update user profile
IAIR_PROtable.Clear()

End If 'if is registered

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' Put in code that checks to see if the user already has info in the aircraftprofile.mdb
' and saves over the info already in it...or creates a new record using the userid and
' fills in the fields with info from textboxes

Dim objUsers As New UserController
Dim objUser As UserInfo

Try
objUser = objUsers.GetUser(PortalId, Int32.Parse(context.User.Identity.Name))
' the above works ONLY if it's a registered user...otherwise it returns an error
Catch ex As Exception
' the user is NOT registered
Label3.Text = "YOU MUST FIRST LOGIN OR REGISTER TO MAKE AN AIRCRAFT PROFILE"

Label3.Visible = True
Return
End Try

Label3.Visible = False

Dim OurUserID As String

If Not objUser Is Nothing Then
OurUserID = objUser.UserID.ToString
End If

Dim AIR_PROdb As New OleDb.OleDbConnection
Dim GetAIR_PRO As New OleDb.OleDbCommand
Dim AIR_PROAdapter As New OleDb.OleDbDataAdapter
Dim AIR_PROds As New DataSet

Try

AIR_PROdb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSourcePath & "aircraftprofile.mdb"
GetAIR_PRO.CommandText = "Select * from AIR_PROFILE WHERE user_id='" & OurUserID & "'"
GetAIR_PRO.Connection = AIR_PROdb
AIR_PROAdapter.SelectCommand = GetAIR_PRO

AIR_PROdb.Open()
Catch ex As Exception
SysError = True
ErrorRpt &= "***There was a problem accessing the Aircraft Profile database: " & ex.ToString
End Try

Try

AIR_PROAdapter.Fill(AIR_PROds, "AIR_PROFILE")

Catch ex As Exception
SysError = True
ErrorRpt &= "***There was a problem filling the dataset from the Aircraft Profile database: " & ex.ToString
End Try

Dim AIR_PROtable As DataTable = AIR_PROds.Tables("AIR_PROFILE")
Dim mytas, myopweight, myfuel, mymindlength, myminalength, myminwidth, mymaxcross, myburn, myaircat, myairtype As Integer 'going to use the index values for the dropdownlists...

mytas = Textbox19.Text
myopweight = TextBox7.Text
myfuel = TextBox8.Text
mymindlength = Textbox4.Text
myminalength = Textbox9.Text
myminwidth = Textbox5.Text
mymaxcross = Textbox6.Text
myburn = Textbox20.Text
myaircat = Dropdownlist2.SelectedIndex
myairtype = DropDownList1.SelectedIndex


If AIR_PROtable.Rows.Count = 0 Then
' First time user has saved a profile
GetAIR_PRO.CommandText = "Insert into AIR_PROFILE(User_Id,tas,op_weight,fuel_load,air_cat,min_dpt_length,min_arr_length,min_width,max_cross,air_type,burn_rate) values (" & OurUserID & "," & mytas & "," & myopweight & "," & myfuel & "," & myaircat & "," & mymindlength & "," & myminalength & "," & myminwidth & "," & mymaxcross & "," & myairtype & "," & myburn & ")"

ElseIf AIR_PROtable.Rows.Count = 1 Then
' He's updating already existing info
GetAIR_PRO.CommandText = "UPDATE AIR_PROFILE SET tas='" & mytas & "', op_weight = '" & myopweight & "', fuel_load = '" & myfuel & "', air_cat = '" & myaircat & "', min_dpt_length = '" & mymindlength & "', min_arr_length = '" & myminalength & "', min_width = '" & myminwidth & "', max_cross = '" & mymaxcross & "', air_type = '" & myairtype & "', burn_rate = '" & myburn & "' WHERE user_id = '" & OurUserID & "'"

Else
SysError = True
ErrorRpt &= "User tried to edit Aircraft Profile and while searching for UserID in database found more than one userid. "
Return

End If

GetAIR_PRO.ExecuteNonQuery() 'now that the proper command has been made...execute it

' CLEAN UP
AIR_PROdb.Close()
AIR_PROds.Clear()
AIR_PROtable.Clear()

End Sub
DotNetNuke Bronze Benefactor
lilryno
Asp.Net User
Re: Plugging holes in a dyke... (datasets and SQL statements) - kinda complicated6/13/2004 11:36:01 PM

0

Now if I take out all that page_load code...then the updater works wonderfully but the module doesn't load the textboxes with information on the initial load. I'm still tinkering with this sloppy code but think I'll have it fixed before too long.
DotNetNuke Bronze Benefactor
lilryno
Asp.Net User
Re: Plugging holes in a dyke... (datasets and SQL statements) - kinda complicated6/14/2004 2:28:01 AM

0

Figured it out. Page_Load needed a "If not IsPostback" statement.... always something easy.
DotNetNuke Bronze Benefactor
scottrait
Asp.Net User
Re: Plugging holes in a dyke... (datasets and SQL statements) - kinda complicated6/14/2004 1:27:57 PM

0

Hmm . . .I posted a response about not ispostback right after I saw your post but it never showed up. Sorry!
lilryno
Asp.Net User
Re: Plugging holes in a dyke... (datasets and SQL statements) - kinda complicated6/14/2004 10:38:18 PM

0

No problem man! It's good for me to figure stuff out on my own from time to time instead of relying on all you real programmers. From time to time, that is. Ha ha. Thanks man.
DotNetNuke Bronze Benefactor
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Dataset 2626, 3305, Engineers Find Hole in Space Shuttle - ABC News ...... 4952, 5631, G7: Japan Omi:Don't Expect Specific FX Remarks In Statement-2 ...
The Bearcave Links Page Wallace is a good example of the kind of scum that take part in SPAM "marketing" . ...... TOAD provides a very nice interface for entering SQL statements. ...
Planet NEO Open Source is hip & happenin’ in a far out kinda way. ..... Prints the CREATE TABLE SQL statements for the given app name(s). sqlall [appname . ...
eBooksBay » PDF-CHM-Books-Catalogue-- » July 2008 Terracotta, Inc. delivers plug–in capacity and availability for Java ...... and functions, as well as SQL*Plus and PL/SQL statements and options. Softcover. ...
March 2008 at Source Code | Free Indo Source Code ~ Technology ... At this time, there's no official statement regarding this potential ...... SEATTLE (AP) -- Microsoft Corp. plans to buy Rapt Inc., plugging a hole in its ...
Open Comments Create some kind of interactive display with our photos to help get people ... If gmail could integrate with SF for emai, and plug a wiki in there too for ...
June 2006 Vol.30, No.2 ISSN 0196-6006 ating indexes using the INDEX data set option, the DATASETS and SQL. procedures, a WHERE expression, a BY statement, or the KEY option. ...
Search Engine Roundtable: Search Marketing Expo 2008 Seattle Archives When you plug in a product search (dell desktop *), you can see what people are ...... With search in the mix, all designs built from 1995-2000 kind of have ...
VB Helper: Karen Watterson's Archived Destinations and Diversions ... 301248 How to update a database from a DataSet object with VB.NET. ...... Tom Moulder's article of picking the best DB2 SQL statements to tune. ...
Springer Catalog makes when parsing a SQL statement and choosing. an access plan. It demonstrates how the CBO ...... and evaluating plug-ins to build a suite of enterprise ...












skin : error server : can someone check my files, please?

where is the access .mdb located

no longer able to upload

help with dns

3.1.1 installation issues

free skin for testing with dnn4.0

dnn4 missing installation file?

new installation issue

i don't know where is the error

evaluation questions

sql server v7? will it work ?/

what is the portals/guid folder?

install problems

google sitemap

machine.config error on install

create new parent portal

start/end date... but what about time?

a very generic questic

security/sharing permissions

redirection problem??

can't loaded into the webform designer !

new to dnn - how to install missing modules

mysql and dotnetnuke

error when i am trying to install on my host

dnn 3.0.7 c# modules

regarding to building given projects in dotnet nuke

compilation error please help me

problems installing on a win 2003 domain controller

ico files not available for icon selection

docs 4.0.3 - disappointing

newbie

dnn 2.12 not working on w2k pro/msde 2k/iis 5.0?

compiler error message: bc30451: name 'config' is not declared.

getting error "an unhandled error has occurred." when trying to access my dnn

solpartmenu vs menu in dnn3.1

dnn 3.05 installation problem

global.asax

who can help me out? wh4l obviously can't!

how to prenvent files from downloading?

getting rid of the horizontal rule in the module title.

installing dnn3.1 without dbo rights on sqlserver

newbie question

dnn 3 and permission issue

vs 2005 & dnn 2-3

"upgrade error" installation problem.

secure connection string in registry

help!sos

text/html, links and other standard modules is not available after installation

newbie needs some help

web.config?

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT