Jump to content
Xtreme .Net Talk

Aspnot

Avatar/Signature
  • Posts

    37
  • Joined

  • Last visited

Everything posted by Aspnot

  1. You can also try putting a break in after you build strSQL and determine exactly what strSQL states. Then copy and paste that into a query in MS Access and then try to execute it. MS Access usually gives better info about the error when you do it that way.
  2. ---------------- For example: Customer1/Header.asp has an IMG tag like <IMG src="Images/Header.gif">. When I call Customer1/Survey/Default.asp and it does an include of Customer1/Header.asp, the IMG tag uses a relative reference from Customer1/Survey and not the root Customer1 folder. That means that it is looking for Header.gif in the Customer1/Survey/Images folder that does not exist. If I were to use <IMG src="../Images/Header.gif"> in the Header.asp include file that would work in this case. But, what would happen if I called Header.asp from a folder called Customer1/Survey/2005_Survey ---------------- I would prefer to start the pathing at the root of the Customer1 site and then work my way out. That way I could always use Header.asp as an include and just use <IMG src="/Images/Header.gif">. However, since this development machine hosts multiple sites, this would send it to the root of the port 80 web site looking for a folder named Images that doesn't exist. There has got to be an easy solution to this. There is no way that I am the only one who has ever wanted to do things this way. I must be missing something really obvious here....
  3. No one can point me in the right direction here? Am I missing something real simple?
  4. Here's what I see at first look. You are setting myCmd equal to the connection object's command and it needs to be the other way around. Replace 'Create a SQL Command Object to query Patient by MedRec number myCmd = objConnection.CreateCommand myCmd.CommandText = "SELECT Med_Rec#, RAD#, First_Name," & _ "Last_Name, Sex, Birth_Date, Soc_Sec#, Last_Exam_Date " & _ "From tblPatient " & _ "WHERE Med_Rec#= '" & strMed_REC & "'" objConnection.Open() myReader = myCmd.ExecuteReader() With 'Create a SQL Command Object to query Patient by MedRec number With myCmd .CommandText = "SELECT Med_Rec#, RAD#, First_Name," & _ "Last_Name, Sex, Birth_Date, Soc_Sec#, Last_Exam_Date " & _ "From tblPatient " & _ "WHERE Med_Rec#= '" & strMed_REC & "'" .CommandType = CommandType.Text .Connection = objConnection End With objConnection.Open myReader = myCmd.ExecuteReader() That should do it for you. Now... You mention that you are accessing a SQL Server. I would recommend taking your CommandText and creating a Stored Procedure out of it. Then change .CommandType = CommandType.Text to .CommandType = CommandType.StoredProcedure. For Example: Stored Procedure Create Procedure dbo.GetPatientByMedRec @MedRec int AS Select Med_Rec#, RAD#, First_Name, Last_Name, Sex, Birth_Date, Soc_Sec#, Last_Exam_Date From tblPatient WHERE Med_Rec#= @MedRec Command Object With objCommand .CommandText = "GetPatientByMedRec" .CommandType = CommandType.StoredProcedure .Connection = objConnection .Parameters.Add("@MedRec", SqlDbType.Int).Value = txtGetMedRec.Text End With
  5. I have a server running IIS 6 with multiple websites that I maintain on it. Each site gets promoted to a separate web host, depending on the customer's selection. A representation of the development server's configuration is below. DEV Website Customer1 Images Survey Customer2 Customer3 Customer4 I have been able to get the Customer1\Survey\Default.asp page to reference the Customer1\Header.asp include file by turning on the Enable Parent Paths in IIS 6.0 and using <!-- #Include File="../Header.asp" --> (Note that I would prefer to use this without the .. in it to reference the customer's root folder.). Now the Header.asp file loads an image that is in the Customer1\Images folder and since this is being called from the Default.asp page in the Survey folder, I have no way to reference it without using a .. in the <IMG> tag in the Header.asp file. Doing this would cause all of the pages in the Customer1 root to try to step down to the root of the webserver and it would never find the file. I know that I could use VIRTUAL, but that wouldn't work once the site was uploaded to the web host. (I know this is a rather convoluted scenario, but I cannot think of a way to make it any easier to read. Sorry.) Is there a way to set this up so that I can get all of these sites to work together properly on the dev server and still work properly once uploaded to the web host's server.
  6. I am not sure of exactly what you are going to do with the dataset once you have it back, so this follows the example you were using above. Dim myOleDbConnection As Data.OleDb.OleDbConnection Dim myOleDbDataAdapter As Data.OleDb.OleDbDataAdapter Dim myOleDbCommand As Data.OleDb.OleDbCommand Dim myDataSet As DataSet Dim myDataTable As DataTable Dim inkindSQL As String = "SELECT *, SUM([Donation Amount]) FROM Donations WHERE [Resources Cash/In-Kind] = 'Resources In-Kind' AND [Date Donation Made] BETWEEN report_start AND report_end" Dim cashSQL As String = "SELECT *, SUM([Donation Amount]) FROM Donations WHERE [Resources Cash/In-Kind] = 'Resources Cash' AND [Date Donation Made] BETWEEN report_start AND report_end" With myOleDbConnection .ConnectionString = "Connection String Text" If .State = ConnectionState.Closed Then .Open() End With With myOleDbCommand .CommandText = inkindSQL .CommandType = CommandType.Text .Connection = myOleDbConnection End With myOleDbDataAdapter.SelectCommand = myOleDbCommand myOleDbDataAdapter.Fill(myDataSet) If you are only going to read the data, I would remove the dataset and the dataadapter and go with a OleDbDataReader and replace the block above with With myOleDbCommand .CommandText = inkindSQL .CommandType = CommandType.Text .Connection = myOleDbConnection myOleDbDataReader = .ExecuteReader End With If you could use all of the data in one read from the database, I would look into the earlier example I gave with the Group By clause in it. With this, you would have to run it twice for each SQL string you made.
  7. OK. Assume there was databinding involved. <%# DataBinder.Eval(Container, "DataItem.Abstract") %> Versus <asp:Label id="Abstract" runat="Server"><%# DataBinder.Eval(Container, "DataItem.Abstract") %></asp:Label>
  8. I am unsure of whether there is any benefit to coding one way versus another, so I thought this would be a good place to ask my question. Is there any benefit or advantage to Method 1 vs. Method 2? Method 1 <asp:Label id="Label1" runat="Server>Some Text</asp:Label> Method 2 Some Text I know the purist tells me to use Method 1, but that's a lot more code to sort through than Method 2. It would appear to me that all the <ASP:> tags are doing is getting interpreted by the server and that would lead me to believe there is more overhead involved with this method... Thoughts, suggestions, preferences? Thanks in Advance!!
  9. The layout I want is something like Headline Title (a few spaces) Date Text of the abstract goes here. Blah Blah Blah There may be up to 5 headlines at any given time. How would I preload the ASP.NET form to be able to handle this? Can I just use a container control and then populate it with the necessary controls at runtime? Just trying to get a grip on this. Thanks!!
  10. From first look, it appears that you are getting back a Null value from the database for the Resources Cash/In-Kind field. I would run the query in Access or SQL Query Analyzer (not sure what DB you are using) and look to see if there is a Null value. To handle the Null value, I would write a function similiar to Function CheckNull(ByVal inVal) as String If IsNull(inVal) Then Return "" Else Return inVal End If End Function It's been a while since I wrote something like that in VB.NET, but that should get you close. Have you considered adjusting your query so that the DB does the work for you? I would recommend using a query similiar to: Select [Resources Cash/In-Kind], Sum([Donation Amount]) FROM TableName WHERE [Resources Cash/In-Kind] IN ("Resources In-Kind", "Resources Cash") GROUP BY [Resources Cash/In-Kind] That should return you return you something like: Resources Cash 110,000.00 Resources In-Kind 100,000.00
  11. I have been an ASP developer for years and am trying to get my arms around ASP.NET. I am trying to call a function from my ASPX file that exists in my VB file. The function makes a call to SQL Server to get a list of records to display. I am trying to do all of the looping in the VB file and just have that information returned to the ASPX file with a Response.Write. I have seen somewhere where the person created the DataReader in the ASPX file and then referenced it from the VB file. This allowed him to loop through the resultset in the ASPX file. I would prefer to do my looping in the ASPX file and return a StringBuilder or a Response.Write or even an HTMLTextWriter. I have also seen where I can create a namespace and do it that way. Again, this just feels too clunky. Maybe this is the best way to do it, but I really don't know. What do you folks do? I would like to see a couple of different suggestions so that I can debate the pros and cons. Thanks in advance!!
  12. I am writing a utility that needs to query AD and return back to me all sub-OUs of the OU passed in. However, I would like to be able to load this information into a Treeview with the results of only one query. (The DC I will be querying is across my WAN connection.) I can use the following code: Dim adsRoot As New DirectoryEntry("LDAP://OU=SourceOU,DC=myDomain,DC=com") Dim adsSearch As New DirectorySearcher(adsRoot, "(&(objectClass=organizationalUnit))") Dim result As SearchResult Try For Each result In adsSearch.FindAll() ???????? Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try The problem I have here is that I cannot see the Children of a given result object. I can use result.GetDirectoryEntry().Children to return back access to a DirectoryEntries collection. But, from what I can tell, this makes another query back to the DC. The only solution I can see is to parse out the result.Path. That would be painful and there has to be a better way. Any assistance would be greatly appreciated!!
  13. Yeah. I played around with it Friday evening and found that before setting the .CurrentRowIndex, I can do an .UnSelect and that does the trick.
  14. I have an application that I am working on that uses a DataGrid. I am using it like I used to use the ListView in VB6. That is, it is just for displaying data and I have dialog boxes that allow for editing and creating new data. I have it currently set to select the entire row when someone clicks on a cell in the row. That works perfectly. However, I want a right-click to be able to select a row and then show the context menu. I have it selecting the row, but it also leaves the previously selected line highlighted, as well. Any ideas on how to remove selections on a datagrid? Here is the code I am using on MouseDown to select the row on right-click. If e.Button = MouseButtons.Right Then Dim pt = New Point(e.X, e.Y) Dim hti As DataGrid.HitTestInfo = dgMain.HitTest(pt) If hti.Type = DataGrid.HitTestType.Cell Then dgMain.CurrentCell = New DataGridCell(hti.Row, hti.Column) dgMain.CurrentRowIndex = hti.Row dgMain.Select(hti.Row) End If End If
  15. Try doing something like: SELECT Sum(Cost) from BookingsTable GROUP BY BookingID If you are just looking for the BookingIDs and don't care to do any aggregate functions, then you can just use something like: SELECT DISTINCT BookingID from BookingsTable
  16. In the VB6 world, I quite often used a class module for returning data from SQL Server. I would have the function return a disconnected recordset. What is the best way to do this in VB.NET that can still be bound to a control? Typed Dataset - The problem here is what if I want to query the data from a table and also return a count. That doesn't match the table's structure. (I could create another structure to hold it, but that makes the schema even larger.) Not to mention I could feasibly have 50+ tables. I really don't want to create a huge XSD schema for all of it. Untyped Dataset - The problem here is that you have no easy way to control the naming of the columns in say a datagrid like you do in a Typed Dataset. These are the main 2 things I have tried. I know their are other ways and that is where I hope you all can shed some light for me and show me the pros and cons of the other ways. What are you folks doing for getting data back out of SQL Server that keeps all of your DB interaction code in a tight package? Thanks in advance.
  17. As I am sure you are aware, you will want to use a Where clause in your SQL. Aside from that, it looks perfect. When a user selects to checkout, you will have to insert your necessary records into both tables individually. You will first insert into tblOrders and then get back from that insert the ID for the item you just created. Then you use that ID to insert records into tblOrderDetails. PS - What database are you using here?
  18. Having a table in the DB for all of the line items is the typical way of doing this. It saves on DB space since you aren't needing to store customer info multiple time. You should have something like the following: Orders Table: Order_ID Customer_ID (relates back to customer table if you are storing customers, else you would store the customer's name and info here) OrderDetails Table: OrderDetail_ID Order_ID (relates back to the orders table) Iventory_ID QtyOrdered SalesPrice etc. When you create your report in Crystal Reports, point the data source to either a Stored Procedure or just create your own query from within CR. You will just need to inner join your Orders and OrderDetails tables on the Order_ID field. If you already are aware of the above, sorry for the primer. Doing queries like this should not overly tax out your DB server. That is what ALL of the accounting systems I have worked with do. That is also what I do when I create tables to store order info. PS - On the OrderDetails table, setup an index on the Order_ID field so that the join runs faster.
  19. Have you thought about making a report in Crystal Reports? Most of the accounting systems I work with use Crystal Reports for invoices, receipts, etc.
  20. Aspnot

    Class.Class

    Thanks wessamzeidan. That is exactly what I was wanting to do. This sparks 2 questions: 1 - Is this a dumb way to do this? Is there a better way? Am I just being anal about wanting it done this way? 2 - Is there a way to just reference my GetData class that is in another .vb file, or do I need to have it in the same .vb file as the Namespace? Thanks again!! You have been a big help.
  21. Aspnot

    Class.Class

    I see what you are getting at, but it seems that this is the long way around it. I want to do something similiar to the System namespace. You can't set something equal to System, but you can set something equal to System.Data.SqlClient.SqlConnection. This is what I want to do. I don't want the user to be able to create an instance of the AppData class. I want them to have to create an instance of the AppData.GetData class.
  22. In this application that I am working on, I have a AppData class. Inside of this AppData class I want to have a DelData class, a GetData class, a SaveData class, etc. When I use the AppData class, I want to be able to do the following: Dim x as AppData.GetData I initially created the AppData class and then created instances of the other classes within it. The problem here is that the New constructor of the AppData class has to create NEW instances of the sub classes. I don't like doing this as it loads all of my sub classes when they aren't really needed. Also, I have to reference them like: MyVal = x.GetData.FunctionName I must be missing something real easy here, but I just don't see it. Any assistance would be greatly appreciated!!
  23. You can do it at runtime with a statement like: ListView1.Columns(0).TextAlign = HorizontalAlignment.Left If you know that you will always have just 3 columns, then you can also adjust this at design time. You will have to make sure that you set the View property to Details. Then you can go into the Columns collection and setup the columns there. I hope this was what you were referring to.
  24. Crystal Reports supports most Avery labels. You could create a report that prints the labels for you. I have done it this way many times.
  25. I was using the Inherited Form wizard. I played around with it some at home this weekend and determined that the modifier for the buttons of "Protected Friend" was the problem. When I set it to "Protected" it works fine. Now off to the MSDN library to determine exactly what each of these modifier options represents. Thanks for the reply
×
×
  • Create New...