TFS was not designed to be run for Visual Studio 2003. However, there are a couple of ways you can use VS 2003 with TFS.
Workaround:
1. Create a TFS workspace, and put the VS 2003 Source code and project into it.
2. In the VS 2005, open the Source Control Explorer (View > Other Windows > Source Control Explorer). Get Latest of the 2003 Version (Right Click on the folder). This gets all the code to the client system without trying to open the solution or any of its projects, which would trigger the VS 2003 to VS 2005 conversion wizard. If this is run, it will make the project unusable.
3. From here you work with the project using an instance of VS 2003, using the separate VS 2005 instance to do your check-outs and check-ins.
Another Solution:
Download and install the Visual Studio 2005 Team Foundation Server MSSCCI Provider. According to the Microsoft page, this should work with the following:
Visual Studio .NET 2003
Visual C++ 6 SP6
Visual Visual Basic 6 SP6
Visual FoxPro 9 SP1
Microsoft Access 2003 SP2
SQL Server Management Studio
Sparx Systems Enterprise Architect 6.1
Sybase PowerBuilder 10.5
Toad for SQL Server 2.0
If you do not have it installed, you will need The team Explorer 2005.
Once you installed both of them. You will have a little problem: you will not be able to use VSS anymore. But there is another workaround!
To be able to choose again which source control you want to use (VSS or TFS), you will need to change some registry keys information. While it's easy to do so, I prefered to just download another tool that will allow me to switch back and forth.
The tool is called SCC Switcher, you can download it from http://www.codeproject.com/KB/applications/sccswitcher.aspx
Tuesday
Saturday
Inserting multiple selected items
You have a listbox where you need to deal with multiple items selected. I guess this should be very easy, but still it's worth to write about it.
Parameter p;
for (int i = 0; i < listbox.Items.Count; i++)
{
if (listbox.Items[i].Selected)
{
p = new Parameter("param", TypeCode.String, listbox.Items[i].Value);
myDS.InsertParameters.Add(p);
myDS.Insert();
myDS.InsertParameters.Remove(p);
}
}
Parameter p;
for (int i = 0; i < listbox.Items.Count; i++)
{
if (listbox.Items[i].Selected)
{
p = new Parameter("param", TypeCode.String, listbox.Items[i].Value);
myDS.InsertParameters.Add(p);
myDS.Insert();
myDS.InsertParameters.Remove(p);
}
}
Command button in a Gridview
Suppose you are displaying records in a gridview and would like to create a command button where you click on and send an email to the memberID for example.
In case you are not displaying the memberID, you should use the following syntax for doing the job:
if (e.CommandName.ToString() == "cmdContact")
{
int MemberID = (int)GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;
//then do something with the memberID value.
In case you are not displaying the memberID, you should use the following syntax for doing the job:
if (e.CommandName.ToString() == "cmdContact")
{
int MemberID = (int)GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;
//then do something with the memberID value.
Thursday
identity insert with SQL (instead of SQL procedure)
You can do the same start you did with the stored procediure. Except that in the _Inserted Event you do:
DbCommand command = e.Command;
string eid;
command.CommandText = "SELECT @@IDENTITY";
eid= command.ExecuteScalar().ToString();
DbCommand command = e.Command;
string eid;
command.CommandText = "SELECT @@IDENTITY";
eid= command.ExecuteScalar().ToString();
How to save a word document in the database.
How to save a word document in the database.
protected void btnFileUpload_Click()
{
byte[] fileData = null;
try
{
string FileExtention;
if ((m_File != null)&&(m_File.PostedFile != null) && (m_File.PostedFile.ContentLength > 0))
{
int size = m_File.PostedFile.ContentLength;
if (size < 102400)
{
if (ExtentionOK("pdf") || ExtentionOK("doc") || ExtentionOK("rtf") || ExtentionOK("txt"))
{
FileExtention = System.IO.Path.GetExtension(m_File.PostedFile.FileName);
string fn = System.IO.Path.GetFileName(m_File.PostedFile.FileName);
Stream MyStream = m_File.PostedFile.InputStream;
long iLength = MyStream.Length;
fileData = new byte[(int)MyStream.Length];
MyStream.Read(fileData, 0, (int)MyStream.Length);
MyStream.Close();
SqlConnection MyConnection = new SqlConnection("Data Source=myserver;Integrated Security=SSPI;Initial Catalog=Mydatabase");
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("INSERT INTO mytable (myfile) VALUES (@doc_content)", MyConnection);
SqlParameter param1 = new SqlParameter("@doc_content", SqlDbType.Image);
param1.Value = fileData;
MyCommand.Parameters.Add(param1);
MyCommand.ExecuteNonQuery();
}
else
Reponse.Write("File extention not allowed");
}
else
Reponse.Write("File too big. You are only allowed 100K for the resume");
}
else
Reponse.Write("Please select a file to upload");
}
catch (Exception excep)
{
ExceptionCatching(excep);
}
protected void btnFileUpload_Click()
{
byte[] fileData = null;
try
{
string FileExtention;
if ((m_File != null)&&(m_File.PostedFile != null) && (m_File.PostedFile.ContentLength > 0))
{
int size = m_File.PostedFile.ContentLength;
if (size < 102400)
{
if (ExtentionOK("pdf") || ExtentionOK("doc") || ExtentionOK("rtf") || ExtentionOK("txt"))
{
FileExtention = System.IO.Path.GetExtension(m_File.PostedFile.FileName);
string fn = System.IO.Path.GetFileName(m_File.PostedFile.FileName);
Stream MyStream = m_File.PostedFile.InputStream;
long iLength = MyStream.Length;
fileData = new byte[(int)MyStream.Length];
MyStream.Read(fileData, 0, (int)MyStream.Length);
MyStream.Close();
SqlConnection MyConnection = new SqlConnection("Data Source=myserver;Integrated Security=SSPI;Initial Catalog=Mydatabase");
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("INSERT INTO mytable (myfile) VALUES (@doc_content)", MyConnection);
SqlParameter param1 = new SqlParameter("@doc_content", SqlDbType.Image);
param1.Value = fileData;
MyCommand.Parameters.Add(param1);
MyCommand.ExecuteNonQuery();
}
else
Reponse.Write("File extention not allowed");
}
else
Reponse.Write("File too big. You are only allowed 100K for the resume");
}
else
Reponse.Write("Please select a file to upload");
}
catch (Exception excep)
{
ExceptionCatching(excep);
}
How to get a return value from a stored procedure using .net 2.0
How to get a return value from a stored procedure using .net 2.0
Suppose you are working with a stored procedure that insert a specific record that has identity on. You want then to return that identity number to insert in another table:
Here is the stored procedure code:
CREATE PROCEDURE dbo.InsertEvent_sp(@EventID INT =0 ,--this is the identity column@EventDate smalldatetime ,
@EventTitle nvarchar(100))AS
BEGIN SET NOCOUNT ON INSERT
INTO tblEvent (EventDate, EventTitle)
values (@EventDate, @EventTitle)SET @EventID = @@IDENTITY
return @EventID
END
GO
Then you would need to use this stored procedure in your SqlDataSource...Then once you insert the record using the datasource, you have to creat a new event for the inserted event: OnInserted="EventDS_Inserted" in the SqlDataSource tag.
Then in the code: EventDS_Inserted would be like:
protected void EventDS_Inserted(object sender, SqlDataSourceStatusEventArgs e){
DbCommand command = e.Command; //do not forget to add using System.Data.Common; in the declarations section.
string eid;
string Speaker, SpeakerTitle;
eid = command.Parameters["@EventID"].Value.ToString();
}
Suppose you are working with a stored procedure that insert a specific record that has identity on. You want then to return that identity number to insert in another table:
Here is the stored procedure code:
CREATE PROCEDURE dbo.InsertEvent_sp(@EventID INT =0 ,--this is the identity column@EventDate smalldatetime ,
@EventTitle nvarchar(100))AS
BEGIN SET NOCOUNT ON INSERT
INTO tblEvent (EventDate, EventTitle)
values (@EventDate, @EventTitle)SET @EventID = @@IDENTITY
return @EventID
END
GO
Then you would need to use this stored procedure in your SqlDataSource...Then once you insert the record using the datasource, you have to creat a new event for the inserted event: OnInserted="EventDS_Inserted" in the SqlDataSource tag.
Then in the code: EventDS_Inserted would be like:
protected void EventDS_Inserted(object sender, SqlDataSourceStatusEventArgs e){
DbCommand command = e.Command; //do not forget to add using System.Data.Common; in the declarations section.
string eid;
string Speaker, SpeakerTitle;
eid = command.Parameters["@EventID"].Value.ToString();
}
Labels:
.Net,
Insert,
SqlDataSource,
Stored Procedures,
Visual Studio 2005,
Web2.0
How to access Formview textfield Data
How to access Formview textfield Data
If you have a formview, and want to access its controls, here is the code for it:
((HiddenField) MyFormView.FindControl("EventDate")).Value= SomeValue;
Of course, you can replace the (HiddenField) with something else, like (TextBox), (CheckBox), etc.
If you have a formview, and want to access its controls, here is the code for it:
((HiddenField) MyFormView.FindControl("EventDate")).Value= SomeValue;
Of course, you can replace the (HiddenField) with something else, like (TextBox), (CheckBox), etc.
Subscribe to:
Posts (Atom)