Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Wednesday, March 28, 2012

How to Schedule a task in Vista

Hi All,

Is Vista get rid of the task scheduling? We can schedule a task easily through the Scheduled Task under control panel, but I cannot find similar stuff in Vista.

Can anyone tell me if schedule a task is still available in Vista? If yes, where can I do that?

Thakns in advance!

Gordon

Ummm... A suggestion, especially for something that isn't released yet:

Search Microsoft's Web site for this information. Or even Google.

Your answer looks to be in the first link when I searched for "windows vista scheduled task" in Google.

Phil|||Good suggestion and will keep in mind!

How to save SQL 2005 solution?

Hi,
I have a solution within SQL 2005, which contains scripts of all
stored procs and views so that they are in source control. My
question is, how can I save this so that every time I open up SQL 2005
management strudio, it appears in the right hand pane, instead of
having to open it up every time.
Thanks for any assistance.How about having a shortcut for the sln file on your desktop?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"nomad" <d.bedgood@.ntlworld.com> wrote in message
news:1172157510.539730.34010@.k78g2000cwa.googlegroups.com...
> Hi,
> I have a solution within SQL 2005, which contains scripts of all
> stored procs and views so that they are in source control. My
> question is, how can I save this so that every time I open up SQL 2005
> management strudio, it appears in the right hand pane, instead of
> having to open it up every time.
> Thanks for any assistance.
>|||On Feb 22, 3:29 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> How about having a shortcut for the sln file on your desktop?
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://www.solidqualitylearning.com/
> "nomad" <d.bedg...@.ntlworld.com> wrote in message
> news:1172157510.539730.34010@.k78g2000cwa.googlegroups.com...
> > Hi,
> > I have a solution within SQL 2005, which contains scripts of all
> > stored procs and views so that they are in source control. My
> > question is, how can I save this so that every time I open up SQL 2005
> > management strudio, it appears in the right hand pane, instead of
> > having to open it up every time.
> > Thanks for any assistance.
Is that the only way? Also, it is very slow loading them all. Think
I might just stick to using souce safe without the solution.

How to save SQL 2005 solution?

Hi,
I have a solution within SQL 2005, which contains scripts of all
stored procs and views so that they are in source control. My
question is, how can I save this so that every time I open up SQL 2005
management strudio, it appears in the right hand pane, instead of
having to open it up every time.
Thanks for any assistance.How about having a shortcut for the sln file on your desktop?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"nomad" <d.bedgood@.ntlworld.com> wrote in message
news:1172157510.539730.34010@.k78g2000cwa.googlegroups.com...
> Hi,
> I have a solution within SQL 2005, which contains scripts of all
> stored procs and views so that they are in source control. My
> question is, how can I save this so that every time I open up SQL 2005
> management strudio, it appears in the right hand pane, instead of
> having to open it up every time.
> Thanks for any assistance.
>|||On Feb 22, 3:29 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:[vbcol=seagreen]
> How about having a shortcut for the sln file on your desktop?
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asph
ttp://www.solidqualitylearning.com/
> "nomad" <d.bedg...@.ntlworld.com> wrote in message
> news:1172157510.539730.34010@.k78g2000cwa.googlegroups.com...
>
>
>
Is that the only way? Also, it is very slow loading them all. Think
I might just stick to using souce safe without the solution.

Monday, March 26, 2012

How to save image in sql server and display that image in datagrid?

Hay Friend's

Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#.

Thank's

Amit

try this link...it display image in data grid...

http://www.odetocode.com/Articles/172.aspx

and for further reference you can refer

http://forums.asp.net/p/1122135/1754824.aspx#1754824

|||Hi amit, thanks for ur link but I m not fully Satisfy.. so kindly Send me more solutions..Thank'sAmit|||Hi Amit, Thanks for ur Link, but I m not fully Satisfy. So kindly send me more solutions ThanksAmit|||

Hi,

You can use stream object to insert the image to your database. Here's the sample for you to refer.

1.Store image in database:

Int64 intImageSize;string strImageType;Stream ImageStream;// Gets the Size of the ImageintImageSize = PersonImage.PostedFile.ContentLength;// Gets the Image TypestrImageType = PersonImage.PostedFile.ContentType;// Reads the ImageImageStream = PersonImage.PostedFile.InputStream;byte[] ImageContent =new byte[intImageSize + 1];int intStatus;intStatus = ImageStream.Read(ImageContent, 0, intImageSize);// Create Instance of Connection and Command ObjectSqlConnection myConnection =new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"));SqlCommand myCommand =new SqlCommand("sp_person_isp", myConnection);// Mark the Command as a SPROCmyCommand.CommandType = CommandType.StoredProcedure;// Add Parameters to SPROCSqlParameter prmPersonImage =new SqlParameter("@.PersonImage", SqlDbType.Image);prmPersonImage.Value = ImageContent;myCommand.Parameters.Add(prmPersonImage);SqlParameter prmPersonImageType =new SqlParameter("@.PersonImageType", SqlDbType.VarChar, 255);prmPersonImageType.Value = strImageType;myCommand.Parameters.Add(prmPersonImageType);try {myConnection.Open();myCommand.ExecuteNonQuery();myConnection.Close();Response.Write("New person successfully added!");}catch (SqlException SQLexc) {Response.Write("Insert Failed. Error Details are: " + SQLexc.ToString());}
2. Retrieving Images from SqlServer and displaying in a DataGrid
<asp:TemplateColumn HeaderText="Image"> <ItemTemplate> <asp:Image Width="150" Height="125" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem, "PersonID"))%>' Runat=server /> </ItemTemplate></asp:TemplateColumn>
 
 
//And the method FormatURL (A Server side Function) is as follows.public string FormatURL(object strArgument){return ("readrealimage.aspx?id=" + strArgument);}//And the method FormatURL (A Server side Function) is as follows.public string FormatURL(object strArgument){return ("readrealimage.aspx?id=" + strArgument);}
 
///Database partpublic void Page_Load(object sender, EventArgs e){string strImageID = Request.QueryString("id");// Create Instance of Connection and Command ObjectSqlConnection myConnection =new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"));SqlCommand myCommand =new SqlCommand("Select PersonImageType, PersonImage from das_person_real_images Where PersonID=" + strImageID, myConnection);// I have used the select statement. But it would be much much better, if you //could write a small stored procedure which contains the above sql statement.// Mark the Command as a SPROC (in case, if you wrote the stored procedure//myCommand.CommandType = CommandType.StoredProceduretry {myConnection.Open();SqlDataReader myDataReader;myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);while ((myDataReader.Read())) {Response.ContentType = myDataReader.Item("PersonImageType");Response.BinaryWrite(myDataReader.Item("PersonImage"));}myConnection.Close();}catch (SqlException SQLexc) {}}
Hope that helps. Thanks.
|||

Hi, this is an interesting post. I am curious about if there is something similar you can do to display the SQL image field in a DataGrid in a Windows Forms application too?

Thanks in advance.

Jim

Friday, March 23, 2012

How to run parallely/sequentially

I am having different packages under one project. Each package is having one one control flow, which internally contains one data flow. I want to run these data/control flows in one sequence. I am not able to drag all of these data/control flows into one sequence container. Could anyone tell how to do this in SSIS?

I would create a controller a package, and use Execute Package Tasks to call the existing worker packages. Do not constrain the Execute Package tasks and they will execute in parallel.

|||I didn't get it.

My question is how to run different packages sequentially or parallely. e.g I am loading customer dimension in one data flow(one package). Then I am loading parts dimension using one more package. Then I am loading Calendar Dimension using another package. How do I combine these in a single process flow/workflow, so that one flow can run after/with another .|||You haven't given any details of the workflow you want, so I'll just guess. If I have two dimension load packages and one fact load package I would load my dimensions in parallel, but would want my facts to load after all dimensions for example.

So I would create a new package, the controller package, and add an Execute Package Task to call my Dim 1 package. Then add a second Execute Package Task for my Dim 2 package. Then add a third Execute package task for my Fact package. Now drag and drop the workflow (green dangling lines) from the Dim 1 Exec Pkg Task to Fact Exec Pkg task. Repeat for Dim 2 to Fact.

So now the dimensions are unconstrained and will execute in parallel, but the fact will wait for both dimensions to complete successfully.
Dim1Fact
Dim2||||Thanks DarrenSQLIS, I got it|||The execute package task is working. but when I run my sequence container, which contains 3-4 execute package tasks--it opens up each and every pacakge on my screen (while running). what do I need to do, if I don't want to open them. I want to execute this sequence, without opening up each and every package..|||That's just what the debugger does. If you run it with dtexec (Ctrl-F5) that won't happen. But then you won't get them purty colors. Smilesql

Monday, March 12, 2012

How to Return SqlDataReader and return value (page count) from SPROC

This is my function, it returns SQLDataReader to DATALIST control. Howto return page number with the SQLDataReader set ? sql server 2005,asp.net 2.0

Function get_all_events() As SqlDataReader
Dim myConnection As NewSqlConnection(ConfigurationManager.AppSettings("........."))
Dim myCommand As New SqlCommand("EVENTS_LIST_BY_REGION_ALL", myConnection)
myCommand.CommandType = CommandType.StoredProcedure

Dim parameterState As New SqlParameter("@.State", SqlDbType.VarChar, 2)
parameterState.Value = Request.Params("State")
myCommand.Parameters.Add(parameterState)

Dim parameterPagesize As New SqlParameter("@.pagesize", SqlDbType.Int, 4)
parameterPagesize.Value = 20
myCommand.Parameters.Add(parameterPagesize)

Dim parameterPagenum As New SqlParameter("@.pageNum", SqlDbType.Int, 4)
parameterPagenum.Value = pn1.SelectedPage
myCommand.Parameters.Add(parameterPagenum)

Dim parameterPageCount As New SqlParameter("@.pagecount", SqlDbType.Int, 4)
parameterPageCount.Direction = ParameterDirection.ReturnValue
myCommand.Parameters.Add(parameterPageCount)

myConnection.Open()
'myCommand.ExecuteReader(CommandBehavior.CloseConnection)
'pages = CType(myCommand.Parameters("@.pagecount").Value, Integer)
Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
End Function

Variable Pages is global integer.

This is what i am calling
DataList1.DataSource = get_all_events()
DataList1.DataBind()

How to return records and also the return value of pagecount ? i tried many options, nothing work. Please help !!. I am struck

please any help ? finally following code works without error, but still not returning any return value (pagecount) along with the list of records.

Dim MyReader As SqlDataReader
Dim myConnection As New SqlConnection(ConfigurationManager.AppSettings("Dx918Aveb8ax81"))
Dim myCommand As New SqlCommand("EVENTS_LIST_BY_REGION_ALL", myConnection)
myCommand.CommandType = CommandType.StoredProcedure

Dim parameterregion As New SqlParameter("@.Region", SqlDbType.VarChar, 5)
parameterregion.Value = Request.Params("reg")
myCommand.Parameters.Add(parameterregion)

Dim parameterPagesize As New SqlParameter("@.pagesize", SqlDbType.Int, 4)
parameterPagesize.Value = 10
myCommand.Parameters.Add(parameterPagesize)

Dim parameterPagenum As New SqlParameter("@.pageNum", SqlDbType.Int, 4)
parameterPagenum.Value = pn1.SelectedPage
myCommand.Parameters.Add(parameterPagenum)

Dim parameterPageCount As New SqlParameter("@.pagecount", SqlDbType.Int, 4)
parameterPageCount.Direction = ParameterDirection.ReturnValue
myCommand.Parameters.Add(parameterPageCount)

myConnection.Open()
MyReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
pages = myCommand.Parameters("@.pagecount").Value
DataList1.DataSource = MyReader
DataList1.DataBind()
myCommand.Dispose()
myConnection.Dispose()
Response.Write(pages)

|||Output parameters and return values are not available until after aDataReader is closed (which you should add after your DataBind()).|||thank you. I will try that today!!

Friday, March 9, 2012

How to Retrive single data from sqldatasource control

hi,

i need to code for retrieving single data from sqldatasource control. i need the full set of coding

connecting
retrieving data in text box
editing data to the table
updating data to the table
deleting data to the table

i want to fetch "single field data"

any one who know the code please post reply or send it to my mail senthilonline_foryou@.rediffmail.comI suggest that you use a stored procedure like this (assuming ID is an identity index column, with a data row NAME VARCHAR(50) in Table Fred)

CREATE PROCEDURE dbo.uspGetFred
(
@.ID INT,
@.NAME VARCHAR(50) OUTPUT
)
SET NOCOUNT ON
SELECT NAME FROM Fred WHERE ID = @.ID
GO

The VB code below retrieves NAME into aName fpor a given value of iID
CONST DBCONNECT As String = "Your Connect String"

Dim sName As String = ""
Dim xSqlConnection As SqlConnection = New SqlConnection(DBCONNECT )
Dim xSqlCommand As SqlCommand = New SqlCommand("uspGetFred", xSqlConnection)
Try
xSqlCommand.CommandType = CommandType.StoredProcedure
xSqlCommand.Parameters.Add("@.ID", SqlDbType.Int)
xSqlCommand.Parameters("@.ID").Value = CType(iId, Integer)
xSqlCommand.Parameters.Add("@.NAME", SqlDbType.VarChar, 50)
xSqlCommand.Parameters("@.NAME").Direction = ParameterDirection.Output
xSqlCommand.Connection.Open()
xSqlCommand.ExecuteNonQuery()
sName = xSqlCommand.Parameters("@.NAME").Value
Catch ex As Exception
' Handle your error here!
Finally
xSqlCommand.Connection.Close()
xSqlCommand.Dispose()
xSqlConnection.Dispose()
End Try

HTH!Idea

Friday, February 24, 2012

How to retrieve data from sqldatasource?

Okay, I used the SQLDataSource control to get my data from the databasetable. What or how do I retrieve individual data from thesqldatasource? I want to do some string comparison and manipulationbefore I display it to the browser. How can this be accomplish?

Help is appreciated.

Hi,

The SqlDataSource control designed for data bound controls so you can't access data except by data bound control, for example if your using gridview you can access data item by handle RowDataBound event and make your changes there

I hope this help.

|||

If your DataSourceMode of your SQLDataSource stays as default which is DataSet, you can retrieve a dataview object of your SQLDataSource. If DataSourceMode="DataReader" in yourSQLDataSource, you can retrieve a datareader object.

Here is an example for dataview:

'DataView
Dim mydataview As System.Data.DataView =CType(SQLDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.DataView)

For Each dr As DataRow In dv.Table.Rows
...

Next

'For a Datareader

Dim myreader as System.Data.SqlClient.SqlDataReader = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.SqlClient.SqlDataReader)

While myreader.reader

...

End While

|||Many thanks for the response. Limno, I will try that. In the mean time,if SQLDataSource is for databound only control then what do I need todo so that I can grab the individual field of my table and do datacomparison and then present it on the web?|||

Hi,

It is a way you can access your datasource programmatically.

This link will give a little more information on this topic.http://aspnet.4guysfromrolla.com/articles/022206-1.aspx

|||Okay, here's what I have.

<asp:SqlDataSource ID="sqlEnewsCate" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString%>"
SelectCommand="SELECT * FROM [enewscate] WHERE ([id_ecate] = @.id_ecate) ORDER BY [order_ecate]">
<SelectParameters>
<asp:QueryStringParameter Name="id_ecate" QueryStringField="id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqlEnews" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString%>"
SelectCommand="SELECT * FROM [enews] WHERE ([idmnu_nws] = @.idmnu_nws)">
<SelectParameters>
<asp:QueryStringParameter Name="idmnu_nws" QueryStringField="id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
And here is my code behind in the Page Load:
protected void Page_Load(object sender, EventArgs e)
{
string newsID;
string nwsStory ="";
newsID = Request.QueryString["id"];

if (newsID =="")
{
Response.Redirect("Default.aspx?id=3");
}

if (Request.QueryString["stry"] =="" || Request.QueryString["stry"] ==null)
{
nwsStory ="";
}
OleDbDataReader newsReader = (OleDbDataReader)sqlEnews.Select(DataSourceSelectArguments.Empty);
if (newsReader.Read())
{
if (nwsStory =="" || nwsStory ==null)
{
OleDbDataReader reader = (OleDbDataReader)sqlEnewsCate.Select(DataSourceSelectArguments.Empty);
if (reader.Read())
{
string pic = Convert.ToString(reader["sidePic_ecate"]);
if (pic =="" || pic ==null)
{
imgArticle.ImageUrl ="images/11.jpg";
}
else
{
imgArticle.ImageUrl ="images/" + pic;
}
reader.Close();
}
}
else if (nwsStory =="full")
{
string pic = Convert.ToString(newsReader["sidePic_nws"]);
if (pic =="" || pic ==null)
{
imgArticle.ImageUrl ="images/11.jpg";
}
else
{
imgArticle.ImageUrl ="images/" + pic;
}
}
newsReader.Close();
}
}

And here is the error I received:

erver Error in '/Alumni' Application.

Object reference not set to an instance of an object.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 29: }
Line 30: OleDbDataReader newsReader = (OleDbDataReader)sqlEnews.Select(DataSourceSelectArguments.Empty);
Line 31: if (newsReader.Read())
Line 32: {
Line 33: if (nwsStory == "" || nwsStory == null)


Source File: e:\wwwroot\home\mySite\enews\Default.aspx.cs Line: 31

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
enews_Default.Page_Load(Object sender, EventArgs e) in e:\wwwroot\home\mySite\enews\Default.aspx.cs:31
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42|||

If your DataSourceMode of your SQLDataSource stays as default which is DataSet, you can retrieve a dataview object of your SQLDataSource. If DataSourceMode="DataReader" in yourSQLDataSource, you can retrieve a datareader object.

You need add this to your datasource:

DataSourceMode="DataReader"

|||Thanks for the immediate response. Where in the do I put DataSourceMode="DataReader" in?|||<asp:SqlDataSource ID="sqlEnewsCate" runat="server"DataSourceMode="DataReader" .....|||Thanks! I'll give that a try.|||I still received the same error.|||

You need this in the top of your code behind page too:

using System.Data.OleDb

|||I do have that. I downloaded the source code from the link you gave me.|||

OleDbDataReader newsReader = (OleDbDataReader)sqlEnews.Select(DataSourceSelectArguments.Empty);

and this one:

OleDbDataReader newsReader = (OleDbDataReader)sqlEnewsCate.Select(DataSourceSelectArguments.Empty);

Can you see the problem?

|||Thanks for the response. If you look at my code above, you'll see thatI have both those lines in my code. Unless I did it wrong somehow.

How to retrieve data from a SQLDataSource control

I have made a SQLDataSource control with the select command:

SELECT COUNT(*) AS 'Antall' FROM Utgivelse WHERE (medieID = @.medieID)

I want to use the "Antall" result programmatically in C# code. I try the following statement:

IDataReader MyReader;

MyReader = CType(SqlDataSource2.Select(DataSourceSelectArguments.Empty),IDataReader);

but it doesnot work. Can somebody help me how to get the data from th control ?

Tom

What do you mean by "it does not work"? Do you get an error message? If so, what is it? Also, what database are you accessing? SQL Server? Access? Did you set the mode of the DataSource to DataReader or leave it as the default DataSet?

Have a look at this:http://www.mikesdotnetting.com/Article.aspx?ArticleID=45

Finally, are you using the result from the datasource for any other purpose? If not, you would be better using plain ADO.NET code and ExecuteScalar() for a Count result. If you are binding the result to a control, it would be simpler to read the value from the control once it has been bound.

|||

I got the answer of my problem i the URL you gave me. My working code:

DataView dvSql = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty);

int result;foreach (DataRowView drvSqlin dvSql)

{

result = (int)drvSql["antall"];

if (result > 0)

Label1.Text ="The record is in use and can not be deleted";

Thank a lot for your help !!!

Tom