CodeVerge.Net Beta


   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: > Asp.Net Forum > starter_kits_and_source_projects.commerce_starter_kit Tags:
Item Type: Date Entered: 2/29/2004 10:19:12 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 0 Views: 53 Favorited: 0 Favorite
1 Items, 1 Pages 1 |< << Go >> >|
"MrSelfDestruct
NewsGroup User
Getting data from the database using a loop2/29/2004 10:19:12 PM

0

Below is my code so far. It is a page for sending a mailing list. I have a datagrid showing all the users and there email address. The table EMail has two columns one called EMailID and the other EMail. What I want to do is create a loop which gets out all the email addresses from the table. So how do I do this?
I don't even know how to get a single piece of data out from my database. What would the code be.

Thanks guys.



<%@ Page Language="VB" %>
<script runat="server">

Function MailingList() As System.Data.DataSet
Dim connectionString As String = "server='localhost'; user id='sa'; password='***'; Database='MailingList'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [EMail].* FROM [EMail]"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)

Dim dataAdapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter(sqlCommand)
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function



Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
dgMailingList.DataSource = MailingList()
dgMailingList.DataBind()
End If
End Sub


Sub dgMailingList_Page(sender As Object, e as DataGridPageChangedEventArgs)
'Assign the CurrentPageIndex property to the new page index value
dgMailingList.CurrentPageIndex = e.NewPageIndex

'Rebind the data to the dataGrid
dgMailingList.DataSource = MailingList()
dgMailingList.DataBind()
End Sub



Function DeleteEMail(ByVal eMail As String) As Integer
Dim connectionString As String = "server='localhost'; user id='sa'; password='****'; Database='MailingList'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "DELETE FROM [EMail] WHERE ([EMail].[EMail] = @EMail)"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)

sqlCommand.Parameters.Add("@EMail", System.Data.SqlDbType.NVarChar).Value = eMail

Dim rowsAffected As Integer = 0
sqlConnection.Open
Try
rowsAffected = sqlCommand.ExecuteNonQuery
Finally
sqlConnection.Close
End Try

Return rowsAffected
End Function


Sub btnDelete_Click(sender As Object, e As EventArgs)
'Determine the value of the Product ID Column
Dim EMail as String = delete.text
DeleteEmail(EMail)

dgMailingList.EditItemIndex = -1

dgMailingList.DataSource = MailingList()
dgMailingList.DataBind()
delete.text=""
End Sub


Sub btnSend_Click(sender As Object, e As EventArgs)

' Build a MailMessage
Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mailMessage.From = "ell@frantic.com"
mailMessage.To = "ellalderton@hotmail.com"
mailMessage.Subject = title.text
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text

mailMessage.Body = message.text


System.Web.Mail.SmtpMail.SmtpServer = "frantic.com"
System.Web.Mail.SmtpMail.Send(mailMessage)


Dim connectionString As String = "server='localhost'; user id='sa'; password='sufcea16'; Database='MailingList'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim Ng as String = (SELECT [EMail].Rows(0).* FROM [EMail])
Response.Write(Ng)

End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<h1 align="center">Mailing List
</h1>
<p align="center">
</p>
<p align="left">
<asp:DataGrid id="dgMailingList" runat="server" BorderStyle="None" CellSpacing="2" BorderWidth="1px" BorderColor="#DEBA84" BackColor="#DEBA84" CellPadding="3" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" OnPageIndexChanged="dgMailingList_Page">
<FooterStyle forecolor="#8C4510" backcolor="#F7DFB5"></FooterStyle>
<HeaderStyle font-bold="True" forecolor="White" backcolor="#A55129"></HeaderStyle>
<PagerStyle nextpagetext="Next &amp;gt;" prevpagetext="&amp;lt; Previous" horizontalalign="Center" forecolor="#8C4510"></PagerStyle>
<SelectedItemStyle font-bold="True" forecolor="White" backcolor="#738A9C"></SelectedItemStyle>
<ItemStyle forecolor="#8C4510" backcolor="#FFF7E7"></ItemStyle>
<Columns>
<asp:BoundColumn DataField="EMailID" HeaderText="E-Mail ID"></asp:BoundColumn>
<asp:BoundColumn DataField="EMail" HeaderText="E-Mail Address"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</p>
<p align="left">
</p>
<p align="left">
Delete E-Mail Address:<asp:TextBox id="delete" runat="server" Width="240px"></asp:TextBox>
<asp:Button id="btnDelete" onclick="btnDelete_Click" runat="server" Text="Delete"></asp:Button>
</p>
<p align="left">
</p>
<h2 align="left">Mailing List Message
</h2>
<p align="left">
Title:<asp:TextBox id="title" runat="server" Width="307px"></asp:TextBox>
</p>
<p align="left">
Message:<asp:TextBox id="message" runat="server" Width="554px" TextMode="MultiLine" Height="203px"></asp:TextBox>
</p>
<p align="left">
<asp:Button id="btnSend" onclick="btnSend_Click" runat="server" Text="Send to Mailing List"></asp:Button>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
1 Items, 1 Pages 1 |< << Go >> >|


Free Download:













custom shopping cart

multiple product pages???

store binding value in an variable

doing ad rotator with the starter kit

webmatrix - mk.bat

csk vs2005

iis

catalog manager

error with store procedure

how to create and run a dll file in command prompt? namespace

multi language question

opening commerce starter kit from vb.net

cookie question

strange bug when change currency to try

commerce starter kit on brinkster

localhost

what happens with records in shoppingcart?

shopping cart

dhl shipping services

will pay someone to help get starter kit up and running

ibuyspy store with access

simple globalization/localization question

how to display different categories depending on login?

installing the access version

migrate the sql express to sql server ??

outputcache duration="3600"

system.security.securityexception: requested registry access is not allowed.

can't seem to change product detail links in productslist.aspx

how can execute the storedb.sql under the msde enviroment?

header conflict error in asp.net commerce starter kit

no real cookie in getshoppingcartid-function

how to modify data in sql server

install error: installutillib.dll:clrcreatemanagedinstance errors........

best way to process credit cards and payments with the commerce kit???

server error problem

am i missing something, commerce starter kit

why are people still using .net 1.1 csk?

question about adding an item weight column to products table

commerce starter kit in c#?

combining dal & bll

commerce starter kit for a live environment

unbelievable site example

where are the docs?

server error in '/commercevbsdk' application.

commerce server

unable to find file webuivalidation.js

add wholesale price

login page(dll error)

uninstall problem

different prices for different users

   
  Privacy | Contact Us
All Times Are GMT