Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Thursday, March 29, 2012

Popping opening a mail client and pass a subject parameter...

Hi:

Is there a way to pop open a mail client and pass in a text string for the
subject and possibly other parts of a standard mail message? The "mailto:"
attribute of hyplerlink leaves these blank.

Thanks,
Charlieread up on the mailto: link, it does have a &Subject='text'&Body='text'
attribute IIRC

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com

"Charlie@.CBFC" <charle1@.comcast.net> wrote in message
news:eSlBhiR4DHA.1752@.tk2msftngp13.phx.gbl...
> Hi:
> Is there a way to pop open a mail client and pass in a text string for the
> subject and possibly other parts of a standard mail message? The
"mailto:"
> attribute of hyplerlink leaves these blank.
> Thanks,
> Charlie

Monday, March 26, 2012

populate datagrid

Hello,

Here is the part of my code, I need to add a datagrid and populate is from
this sql string. Can you write the rest of the code?

Dim Da As New OdbcDataAdapter
Dim Ds As New DataSet
Dim cmdSelect As New OdbcCommand

cmdSelect = Conn.CreateCommand
cmdSelect.CommandText = "SELECT * FROM myTable"

Thanks,
Jim.Hope this helps;
<code
/* ### In Web.config BEGIN ### */
<configuration
<appSettings>
<add key="IntranetConnStr_Core" value="Data
Source=<DBServerName_Here>;user
id=<UserID_Here>;password=<Password_Here>;initial catalog=<DB_Here>" />
</appSettings
/* ### In Web.config END ### */

/** Calling code BEGIN **/
Dim dvEventStatuss As New DataView
'Note! strSQLToRun = I read the SQL CMD in from a XLM file.
dvEventStatuss = Do_Get.Do_DBConnection("TBL_EventStatuss", strSQLToRun,
ConfigurationSettings.AppSettings(strConnStr), (strWhoCalledMe &
".Do_DBGridInit"), objVisitor)
With uwgOrderEventStatuss
.DataSource = dvEventStatuss
.DataBind()
end with
/** Calling code BEGIN **/

Public Function Do_DBConnection(ByVal strTBLName As String, ByVal strSQL As
String, ByVal strConnStrToUse As String, ByVal strWhoCalledMe As String,
ByVal objVisitor As clsSiteFunctions.clsUser) As DataView
Dim dvDataView As New DataView
Dim dsDataSet As New DataSet
Dim Connection As New SqlConnection

Try
strConnStrToUse = "IntranetConnStr_Core"
strSQL = "Select * FROM <TableName_Here>"
strTBLName = "TBL_TableName"

Connection.ConnectionString =
ConfigurationSettings.AppSettings(strConnStrToUse)
Dim Adapter As New SqlDataAdapter(strSQL, Connection)
Adapter.Fill(dsDataSet, strTBLName)
Connection.Open()
dvDataView.Table = dsDataSet.Tables(strTBLName)
Adapter.Dispose()
Connection.Close()
Connection.Dispose()
Catch

End Try
Do_DBConnection = dvDataView
End Function

</code
"JIM.H." wrote:

> Hello,
> Here is the part of my code, I need to add a datagrid and populate is from
> this sql string. Can you write the rest of the code?
> Dim Da As New OdbcDataAdapter
> Dim Ds As New DataSet
> Dim cmdSelect As New OdbcCommand
> cmdSelect = Conn.CreateCommand
> cmdSelect.CommandText = "SELECT * FROM myTable"
>
> Thanks,
> Jim.

populate datagrid

Hello,
Here is the part of my code, I need to add a datagrid and populate is from
this sql string. Can you write the rest of the code?
Dim Da As New OdbcDataAdapter
Dim Ds As New DataSet
Dim cmdSelect As New OdbcCommand
cmdSelect = Conn.CreateCommand
cmdSelect.CommandText = "SELECT * FROM myTable"
Thanks,
Jim.Hope this helps;
<code>
/* ### In Web.config BEGIN ### */
<configuration>
<appSettings>
<add key="IntranetConnStr_Core" value="Data
Source=<DBServerName_Here>;user
id=<UserID_Here>;password=<Password_Here>;initial catalog=<DB_Here>" />
</appSettings>
/* ### In Web.config END ### */
/** Calling code BEGIN **/
Dim dvEventStatuss As New DataView
'Note! strSQLToRun = I read the SQL CMD in from a XLM file.
dvEventStatuss = Do_Get.Do_DBConnection("TBL_EventStatuss", strSQLToRun,
ConfigurationSettings.AppSettings(strConnStr), (strWhoCalledMe &
".Do_DBGridInit"), objVisitor)
With uwgOrderEventStatuss
.DataSource = dvEventStatuss
.DataBind()
end with
/** Calling code BEGIN **/
Public Function Do_DBConnection(ByVal strTBLName As String, ByVal strSQL As
String, ByVal strConnStrToUse As String, ByVal strWhoCalledMe As String,
ByVal objVisitor As clsSiteFunctions.clsUser) As DataView
Dim dvDataView As New DataView
Dim dsDataSet As New DataSet
Dim Connection As New SqlConnection
Try
strConnStrToUse = "IntranetConnStr_Core"
strSQL = "Select * FROM <TableName_Here>"
strTBLName = "TBL_TableName"
Connection.ConnectionString =
ConfigurationSettings.AppSettings(strConnStrToUse)
Dim Adapter As New SqlDataAdapter(strSQL, Connection)
Adapter.Fill(dsDataSet, strTBLName)
Connection.Open()
dvDataView.Table = dsDataSet.Tables(strTBLName)
Adapter.Dispose()
Connection.Close()
Connection.Dispose()
Catch
End Try
Do_DBConnection = dvDataView
End Function
</code>
"JIM.H." wrote:

> Hello,
> Here is the part of my code, I need to add a datagrid and populate is from
> this sql string. Can you write the rest of the code?
> Dim Da As New OdbcDataAdapter
> Dim Ds As New DataSet
> Dim cmdSelect As New OdbcCommand
> cmdSelect = Conn.CreateCommand
> cmdSelect.CommandText = "SELECT * FROM myTable"
>
> Thanks,
> Jim.
>

Saturday, March 24, 2012

Populate string array with a SQL row

Can someone tell why I get an "Invalid attempt to read when no data is present. " error?

Here is the code snipplet . . .


SqlCommand DBCommand = new SqlCommand("SELECT * FROM Addresses WHERE AddressID='"+ID.ToString()+"'", DBConn );
try
{
DBConn.Open();
dr = DBCommand.ExecuteReader( System.Data.CommandBehavior.CloseConnection ) ;

}
catch
{
values = null ;
return values ;
}
values[0]=dr["AddressStreet1"].ToString() ;
values[1]=dr["AddressStreet2"].ToString() ;
values[2]=dr["City"].ToString() ;
values[3]=dr["StateProvinceID"].ToString() ;
values[4]=dr["ZipPostalCode"].ToString() ;
values[5]=dr["CountryID"].ToString() ;

Thanks in advance!You need to read the first record of the recordset:

dr.read();
It works except the first column is gone. Why is that?
Disregard my last message - it was my error.

Wednesday, March 21, 2012

Populating a control with HTML file contents, images included?

publicvoid LoadToLabel()
{
using (StreamReader rdr =newStreamReader(FileUpload1.PostedFile.FileName))
{
string uploadedHTML = rdr.ReadToEnd();
textLabel.Text = uploadedHTML.ToString();
}
}

So far I have that, but the problem is that if the HTML file has an image displayed in it, the image doesn't show up because it's just copying the text. How would I be able to transfer the entire HTML page to a control? Like a panel or something like that, is it possible? And have the images come with it?

You should use LiteralControl for this purpose.


So if I switch it to a literal would it display the images as well?


I just switched it to a literal control and it still ignores the images. What must I do?


Yup. The LiteralControl will display the HTML exactly as you create it. See it as a place holder for output you create from code behind. Good luck!


OK, let me get this straight. You upload a HTML document containing <img> tags, which you then want to print out in the page, right?

If you do a view source in the resulting page, how does it look?

If the image urls in the uploaded page are relative then that is maybe what's causing the problem. Please give an example of how this tag looks like.

Also, if you upload a complete HTML document (with head/body) then you will render a page that is not valid (containing duplicate elements).


What does image urls being relative mean? Like pointing to a specific spot and not "~/Images/image.gif" etc.?

I did a view source on the page that uploads and displays the HTML document and yes you're right, there are now duplicate elements. It uploads everything within the uploaded documents <HTML></HTML> tags. How do I go about just grabbing what's in the body, and not the body tags themselves as that would be a duplicate element as well?


A relative path is one that does not begin with a / or http://something, example:

<img src="http://pics.10026.com/?src=images/ticker.gif">

A relative path is always calculated from the place where it is accessed.

If your (uploaded) page contains relative image paths, then to display these images correctly, you need to either rebuild the path (by parsing), or copy the contents of the path into the same folder as your upload page (not a viable solution).

Or you could make sure the user uploads all the images as well.

In either way, you have some parsing to do in order to get the uploaded file to display correctly. Also you must parse the file to get the actual contents of the file, and get past <html><body> and so on.

One option you have is to show the uploaded file in an iframe which would allow you to show the document as-is (although images would still require parsing).


How would I go about parsing the uploaded file so it displays properly with the images included within the literal control?


Strange... I could almost see that question comingWink Well, parsing text is not trivial, and I am not able to give you the code as it would take some time to develop and test. But here's how I would do: Define a regexp, that finds <img tags, and then replaces the src value with your "path prefixed" value.

Problem is that these tags can come in so many flavours, it's almost impossible to guarantee that the parser matches them correctly. Parsing HTML is kind of re-inventing the wheel again (the wheel being the browser ;-)

Uhm, I'm sorry, can't help you any further with this. But if you google a little on Regular expressions and spend some time trialing and erroring then you might reach your goal. Good luck!


Thank you so much for your help!

Friday, March 16, 2012

Populating a Stream object with XML and then convert Stream into a String Options

I am trying to populate a Stream via an XML Serializer and then
convert that stream of xml into a string.

I have been able to successfully serialize an object into a physical
xml file written to my local disk. The XML file has content and looks
as I would expect, here is the code for that action:

TextWriter writer = new StreamWriter(@dotnet.itags.org."c:\test.xml");
serializer.Serialize(writer, oData);

When I try to to serialize my object to a stream of xml and then
convert to a string I get no content in the string. Both the
MemoryStream and StreamWriter object appear to have the correct byte
size after I populate them with the serialized data. Is there an
alternative way I should be doing this? Here is the code I'm using:

MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);

serializer.Serialize(sw, oData);

StreamReader sr = new StreamReader(ms);

string test = "";
test = sr.ReadToEnd(); //No content is populated, why?

Thank you,
Darren

dstahl:

MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);

serializer.Serialize(sw, oData);

StreamReader sr = new StreamReader(ms);

string test = "";
test = sr.ReadToEnd(); //No content is populated, why?

Thank you,
Darren

Hi Darren,

In your code, after you serialize your sw, you couldn't new it again, because that will create sw again.

Try to cancel that line : "StreamReader sr = new StreamReader(ms); ". As you know, if you do like your way, ms has nothing, then sw has nothing too, even if you have initialize the sw before.

Hope this helps. Thanks.

Populating array with color values

Hi,
I'm trying to populate an array with color names. I keep getting an error.
Here is the line that fails:

Dim Colors As String() = Enum.GetValues(enumColor.GetType())Hi Roger,

You should be able to get all of the colors (including system colors) like
this:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
Dim strSelectedColor As String
Dim enumColor As New KnownColor
Dim Colors As Array = _
[Enum].GetValues(enumColor.GetType())
DropDownList1.DataSource = Colors
DropDownList1.DataBind()
strSelectedColor = DropDownList1.Items(0).Text
End If
End Sub 'Page_Load

Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Label1.Text = DropDownList1.SelectedItem.Text
End Sub

<form id="Form1" method="post" runat="server">
<P>
<asp:DropDownList id="DropDownList1" runat="server"
AutoPostBack="True"></asp:DropDownList></P>
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
</form
Ken
MVP [ASP.NET]

"Roger" <TheFlash@.Superhero.com> wrote in message
news:uguKrq64DHA.2412@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I'm trying to populate an array with color names. I keep getting an
> error.
> Here is the line that fails:
> Dim Colors As String() = Enum.GetValues(enumColor.GetType())
That worked thanks!

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:%236cfSE74DHA.1804@.TK2MSFTNGP12.phx.gbl...
> Hi Roger,
> You should be able to get all of the colors (including system colors) like
> this:
> Private Sub Page_Load _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles MyBase.Load
> If Not IsPostBack Then
> Dim strSelectedColor As String
> Dim enumColor As New KnownColor
> Dim Colors As Array = _
> [Enum].GetValues(enumColor.GetType())
> DropDownList1.DataSource = Colors
> DropDownList1.DataBind()
> strSelectedColor = DropDownList1.Items(0).Text
> End If
> End Sub 'Page_Load
> Private Sub DropDownList1_SelectedIndexChanged _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles DropDownList1.SelectedIndexChanged
> Label1.Text = DropDownList1.SelectedItem.Text
> End Sub
>
> <form id="Form1" method="post" runat="server">
> <P>
> <asp:DropDownList id="DropDownList1" runat="server"
> AutoPostBack="True"></asp:DropDownList></P>
> <P>
> <asp:Label id="Label1" runat="server"></asp:Label></P>
> </form>
> Ken
> MVP [ASP.NET]
>
> "Roger" <TheFlash@.Superhero.com> wrote in message
> news:uguKrq64DHA.2412@.TK2MSFTNGP11.phx.gbl...
> > Hi,
> > I'm trying to populate an array with color names. I keep getting an
> > error.
> > Here is the line that fails:
> > Dim Colors As String() = Enum.GetValues(enumColor.GetType())