?

Log in

Asp Dot Net's Journal
20 most recent entries

Poster:svoysredychuzih
Date:2010-05-28 10:34
Subject:Using DataRelation in DataSet
Security:Public

Hi everybody!
This is the question about how to use DataRelation object.
Let's say I have 2 tables:
SELECT customerId, customerName FROM customers
and
SELECT orderId, customerId, orderName FROM orders
which are related by customerId.

Assume I have method

getDataSet(sqlTextArray)

which returns me the DataSet based on array of queries sqlTextArray

So, then I can write:

String q1 = 
   "SELECT c.customerName, r.orderId, r.orderName "+
   "FROM customers AS c, orders as r "+
   "WHERE (c.ustomerId = r.customerId) ";
String[] q = new String[] { q1 };

DataSet d = getDataSet(q);
DataTable t = d.Tables[0];
for (int i=0; i < t.Rows.Count; i++) {
   String s = t.Rows[i]["customerName"] + ", " + 
      t.Rows[i]["orderId"] + ", " + t.Rows[i]["orderName"] + ".";
   Console.WriteLine(s);
}

This part is clear for me. Then, I want to achieve the same result by using
DataRelation. In this case I should write something like this:
String[] q = new String[] { 
   "SELECT customerId, customerName FROM customers", 
   "SELECT orderId, customerId, orderName FROM orders" 
};
DataSet d = getDataSet(q);
d.Relations.Add(new DataRelation("customer2order",
   d.Tables[0].Columns["customerId"],
   d.Tables[1].Columns["customerId"]));

How to print out the combined data as I did that in first example?

post a comment



Poster:cndnbcn85
Date:2009-11-30 19:27
Subject:
Security:Public

Oh hi, look, second post in a row....

I'm trying to do a multiplication of databinding, but not sure what exactly to google for the simplest solution...

Ideally, I would like to pull from two databases, one pulling product information, including price, then pull from another, pulling a particular discount to multiply by when it matches up with a certain code. So, if you have put in 1234 as the code, it pulls the $100.00 from the product database, and then matches the code with .80 and multiplies the price and the discount, and then just spits out $80.00.

At the very least, I wouldn't mind just having to do one database pull, and multiply the price by a fixed number in the databind field. It's usually the same number anyway when we do updates, but I'm just trying to future-proof it as much as possible.

Is there an easy way to do this and/or a good resource to explain how to do it? I'd like to keep it as simple as possible.

post a comment



Poster:cndnbcn85
Date:2009-10-30 17:52
Subject:Converting Date in SQL Server
Security:Public

I've been looking around everywhere, but either don't know how to search for it or don't know what I'm looking at... but I'm trying to convert dates that I pull from a database from 30/10/2009 00:00:00AM or whatever it comes up as to just the date. I found a convert statement, but have no idea where to put it in my select statement (or if it goes somewhere else).

I tried
SELECT ID, title, caption, credit, date (CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]) FROM MMphotos WHERE (ID = @ID)

and
SELECT * FROM MMphotos WHERE (ID = @ID) CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]

But neither worked... but both returned different errors. First one is saying "'date' is not a recognized built-in function name" and the second was saying "Incorrect syntax near the keyword 'CONVERT'"

What am I mucking up?

9 comments | post a comment



Poster:ivinsky
Date:2009-04-01 23:39
Subject:Подготовка к сертификации Microsoft
Security:Public



Приглашаю в Study Group для подготовки к сертификации Microsoft.

Подробности про Study Group

Цель группы:
Подготовиться к сдаче программерских сертификатов Microsoft. Начнем со сдачи экзаменов по net (Web разработка).

Когда начнем работать?
Работать начнем через две недели. Задачи на эти 2 недели: составить программу курса, разработать план обучения и сдачи экзаменов. Так что присылайте ссылки на книги и др. информацию, которую хотите изучить мне (ведущему группы) скайп или в ЖЖ ivinsky.

Как часто планируется проводить встречи?
Основная задача группы: получение сертификатов Microsoft в кратчайшие сроки, поэтому встречи будут проводиться 5 дней в неделю по вечерам, время уточним позже. Если Вы хотите стать сертифицированным специалистам Microsoft в кратчайшие сроки, то это группа для Вас. Присоединяйтесь!

post a comment



Poster:fuzzygoth
Date:2009-02-17 14:11
Subject:Drag and Drop Listbox
Security:Public
Mood: confused

Hi,
What I am trying to do this time is create an asp.net listbox from
an SQL Server 2005 result set (done) which then users can sort the
records to form the running order within the same Listbox and then
submit all the records including the new running order back into
the database. Each record has already been automatically assigned
a running order number based on their position in the old website.

I am looking for suggestions on the quickest and *easist* way to do
this, examples would be much appreciated. My web application is asp.net
written in C#.

Any help is appreciated.

post a comment



Poster:fuzzygoth
Date:2009-01-28 15:01
Subject:Saving Files from a Website using VB.Net
Security:Public

I have a site that we are moving from Flat HTML into a Database using in house
written VB.Net applications. The website is roughly 10,000 pages. The volume of
pages however is not the problem. The Page HTML content is all now held in a
database, Now I am looping through the pages and checking each page using regular
expressions for either a href or img src tag so I can collect the URL for all
images and attachments. Once I have these, i pass the URL (currently) to the
HttpWebRequest.DownloadData which makes a request to the website for the url
provided and then the attachment is downloaded and eventually written out using
the WriteAllBytes() function. This works for one iterration and then times out.
What i need to know is why does it time out and is there a better method of doing
this? the files can be rather large that are getting moved the site is about 5.7gb
and most of this will be down to diffrent file formats.

3 comments | post a comment



Poster:agnosticfont
Date:2009-01-05 14:14
Subject:Separator lines in asp:menu control
Security:Public

I need separator lines in the dynamic menu section of an asp:menu control.

However, I only want separator lines between certain menu items - not all of them.

Is that possible ?

2 comments | post a comment



Poster:cndnbcn85
Date:2008-11-28 14:46
Subject:update form
Security:Public

I'm trying to create an item update page for a product database, and was wondering if there's something similar to

<asp:SqlDataSource id="updatesel" runat="server"< br /> ConnectionString="server=...;database=...;uid=...;pwd=..."
SelectCommand="SELECT * FROM database WHERE (ID = @ID)" >
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="String"
DefaultValue="%" />
</SelectParameters>

for updating and inserting? I use code like that for search queries, and tried changing "select" to "update" in the code to see if that might work, but no luck. I want there to be a 1st page where you select the product to be updated, then that brings you to a form that has all the product info inserted into the form (with the ID disabled), then you can edit and after submitting, it goes to the 3rd page that gives the success message and updates the table. I have the fist two pages working fine, the form populated with the right data, but after hitting submit, I don't get an error regarding the coding, but no data is updated. I tried using the datagrid method on the MSDN site, because it has worked for inserting new data, but, besides also being kinda bulky to use, it didn't work either. Any suggestions?

1 comment | post a comment



Poster:fuzzygoth
Date:2008-11-28 10:26
Subject:Access the XSD file, Computer says no!
Security:Public
Mood: calm

I keep getting an error the error 1) in my code, I am using a xsd file to call stored procedure and
access the database. This worked fine under Windows 2000 using visual basic express 2005. I am now
on a XP Machine using VS 2005 and i can get it to work. The error occurs at this point 2) and the
code that defines that dataaccess is listed as 3). So what am i doing wrong then all suggestion
accepted.

1) Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

2) content_page = dataaccess.GetContentPages()

3)

Dim content_page As Object
Dim page As Object
Dim page_number As Integer
Dim page_content As String

' call out the pages from the database
Dim dataaccess As DataSet1TableAdapters.pagesTableAdapter = New DataSet1TableAdapters.pagesTableAdapter
content_page = dataaccess.GetContentPages()

' Loop through the record set
For Each page In content_page
' assigned the page and content values to variables
page_number = page
page_content = page

1 comment | post a comment



Poster:fuzzygoth
Date:2008-10-16 15:40
Subject:C# CheckBoxes!
Security:Public
Mood: aggravated

Okay, I am writing a small webapp in asp.net C# 2.0 after a few years
since I last done .net (which was vb.net by the way). I have a GridView
which is filtered by a dropdown, the gridview is listed below. I can't
remember for the life of me how to catch the checkboxes posted back from
the form? and I can't find any simple examples online. Help?

5 comments | post a comment



Poster:svoysredychuzih
Date:2008-09-11 01:18
Subject:.net Class based on SQL Query
Security:Public

I have wrote small script to create container-class based on SQL query (or CSV list of vars)

http://akb.awardspace.com/build_class_based_on_sql.php

Wrote primarily for myself, but everybody is welcome to use it.

post a comment



Poster:svoysredychuzih
Date:2008-08-18 21:30
Subject:Email Message Id
Security:Public

Hello everybody,
Is there a way here to get email message Id right after you send it with the SMPT client?
I am creating a web application on ASP.NET 2.0 and it uses mail server EXIM to send emails.

Message Id I mean that unique identifier, which is being set when you send an email.
Using telnet:

$ telnet yourmailhost.whatever.com 25
<< 220 yourmailhost.whatever.com blah blah
>> HELO yourclientname
<< 250 yourmailhost.whatever.com Hello [ip address]
>> mail from:someaddress@hotmail.com
<< 250 2.1.0 yourmailhost.whatever.com ...Sender OK
>> rcpt to:someaddress@yourmailhost.whatever.com
<< 250 2.1.5 someaddress@yourmailhost.whatever.com
>> data
<< 354 Please start mail input.
>> Subject: Test message
>>
>> This is a test...
>> Testing 1-2-3
>> .
<< 250 Mail queued for delivery. MessageId<K5SHTQ-0004Q0-0E>
>> quit

post a comment



Poster:cndnbcn85
Date:2008-07-12 20:59
Subject:uuugh.... database issues
Security:Public

I'm trying to set up a database connection with ASP.NET in Dreamweaver MX 2004 (yeah, a little older...), and everything in the site has a check mark that needs to before you add a connection, and I add the database file, and even hit test and it registers fine. Then when I go to add a new record set, I select the database, but it says "***No table found". So apparently it's ok with the file path, it just can't read the database tables.

I've made sure the .net framework was all good to go, and I downloaded the MDAC 2.7 files and got those all set. Is there something I'm missing? I'm trying to work with Access and asp.net because that's what a position I'm trying to move into uses, so, I don't really have other options.

Also, I'm thinking maybe there's an issue with drivers because even when I try to hand code it with examples from http://www.w3schools.com/ASPNET/aspnet_repeater.asp, when I call it up in either IE or Firefox, it just displays the code....
any ideas?

post a comment



Poster:svoysredychuzih
Date:2008-06-13 12:03
Subject:Renaming file on-fly
Security:Public

Hello,
I do have a file on web server, let's say 123.zip
When I am redirecting user to it, browser opens Save dialog and puts that name by default: 123.zip. Is there any way to change that name to, let's say 456.zip?
File 123.zip stays on server as 123.zip, but user sees it as 456.zip.

One of the known ways is:

Byte[] data = System.IO.File.ReadAllBytes(sFullName); // 123.zip
Response.AddHeader("Content-Disposition", "attachment; filename=456.zip");
Response.OutputStream.Write(data, 0, data.Length);
Response.End();

But in this case I have to read the whole file first and then stream it out. Works fine with small files, but 123.zip could be huge. Then browser freezes and ends by timeout.

Thank you.

post a comment



Poster:agnosticfont
Date:2008-03-31 08:20
Subject:Multiple web.config files ?
Security:Public

I have content that I only want authorized users to see and then content that I want joe public to be able to view.

I found this article that suggests having two web.config files. So the authorized user content would be in a separate folder with its own web.config file:
http://www.asp.net/learn/security/tutorial-07-vb.aspx

Is that how you would do it ? (There's no date on the article so I didnt know if this was the latest thinking)

Thanks :)

post a comment



Poster:agnosticfont
Date:2008-03-17 13:11
Subject:[SoapDocumentMethod(OneWay = true)]
Security:Public

I am trying to create a "fire and forget" webservice that I can kick off from a webpage.


This is the code I have in the webservice:

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;


[WebService(Namespace = "http://www.tempuri.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


public class TestWebService : System.Web.Services.WebService
{

public TestWebService()
{

//Uncomment the following line if using designed components
//InitializeComponent();
}



[SoapDocumentMethod(OneWay = true)]
[WebMethod]
public void MultipleDatabaseHits()
{

// ..... do a bunch of database stuff

}


}



When I launch it from a page using this code, the page doesnt complete loading untill the database work is done.



protected void Button1_Click(object sender, EventArgs e)
{

TestWebService mySvc = new TestWebService();
mySvc.MultipleDatabaseHits();

}



What am I doing wrong ?



I'm not using RPC for soap so I know that the [SoapDocumentMethod(OneWay = true)] command is the correct one to use. I've seen examples where [SoapDocumentMethod(OneWay = true)] came before or after [WebMethod] - I tried it in both places and it didnt make a difference.

post a comment



Poster:d_aciid
Date:2008-03-12 07:10
Subject:ComboBoxes in two pages.
Security:Public

Hi. I'm newbie both in ASP.NET and in web programming, so my question may be dumb. Sorry if so.
I have two pages in my project and each page contains combo box. Comboboxes bind to one data source.
I need to solve following task: if user select combo box item in one page, the same item must be selected in another page automatically.
Is there any ways to do this or it's impossible?

post a comment



Poster:celeste_spartan
Date:2008-03-03 16:22
Subject:Creating details page based off of Gridview/XML Binding
Security:Public
Mood: confused

I know this is a rather dumb question, but basically I have a main page with a gridview bound to an XML source, and I want you to click on a link that each item has, and when you do that it directs you to a "Details" page (ie you click on a movie title and it directs you to a page that has more info on that movie, with the info being generated from the XML file based on the ID that is sent from the previous page.)

I know how to do this in .Net 1.1, which involved making a separate class and putting the XML info in that, but I imagine there HAS to be an easier way within the 2.0 framework, considering the implementation of Gridview and Detailsview. When I try and have the info binded on the details page, all it does is show the details of the first id, regardless of what id value is passed. I can post the XML file if necessary, but its a rather basic XML setup. I've tried using the XmlDataSource as opposed to manually coding everything myself. I was trained in developing everything by code as opposed to controls that generate it, but I figure if the control can do it more easily and quickly, it isn't a bad idea to learn that method.

So I guess the question is how do you efficiently create a "details" page when trying to pass a value from a previous page and then grab that info from a binded XML file?

;p

TIA

post a comment



Poster:clodappleleft
Date:2008-02-29 16:07
Subject:CollapsePanelExtender and FireFox
Security:Public

I have page that contains a Date Control, update panel, and then a regular panel that is opened or closed via a "CollapsePanelExtender"

When I first load the page, everything works fine, the Panel is open all the way and you can see all of the data. When you change the date, it triggers the UpdatePanel and the panel reloads the data based on the new date. The problem is that the Panel is now "clipped". If I Collapse and then Expand the Panel, it opens to full size and shows everything.

This only occurs in FireFox.

Any ideas?

post a comment



Poster:svoysredychuzih
Date:2008-02-15 11:29
Subject:Reading Page Content of remote web page
Security:Public

Hi there,
For my project I need to read an external web page and then parse the content.
What I have found on the internet is for asp:
<%
url = "http://www.espn.com/main.html"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
Response.write xmlhttp.responseText
set xmlhttp = nothing
%>
And I need the same for ASP.NET 2.0
Can anybody show me how to do that?
Thank you.

1 comment | post a comment


browse
my journal