Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Sunday, March 25, 2012

Adding, Deleting rows from Visual Basic 2005 Express Edition

Hi,

I'm a complete novice concerning SQL Server (Express Edition)

I'm trying to Add or Delete rows froma VB 2005 Express Function or Sub. While the program is running everything is ok. Except when restarted added records are gone and deleted records are back.

Have i missed an option during installation?

Thx,

Steven

Your installation of SQL Server 2005 Express may be operating in 'Snapshot Isolation' mode. Refer to Books Online for more details.

You may also find this series of instructional videos to be useful.

http://msdn.microsoft.com/vstudio/express/sql/learning/default.aspx#1

|||

Make sure that you did not specify the datafile for "Always copy", if you did this, the file will always be copied from scratch upon new start of the Visual Studio debug session.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1611696&SiteID=1

Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

Hi Arnie,

Thx for your trouble, but i got the 'Always Copy' option wrong!

Greetings,

Steven

|||

Hi Jens,

Your answer was the correct one.

Thx,

Steven

Sunday, March 11, 2012

Adding rows together

Hello,
I'm having trouble finding a site with basic introduction to SQL Reporting
Services. I'm using the VS.nET reporting services IDE to build some reports
and I have a few questions.
How do I SUM two "report items" on my report? Like textbox12.value +
textbox13.value. I know how to do it with the "Fields" on my report but not
actualy report items.
Thanks
nTry using the "=ReportItems!Textbox12.value + ReportItems!Textbox13.value".
"nigel" wrote:
> Hello,
> I'm having trouble finding a site with basic introduction to SQL Reporting
> Services. I'm using the VS.nET reporting services IDE to build some reports
> and I have a few questions.
> How do I SUM two "report items" on my report? Like textbox12.value +
> textbox13.value. I know how to do it with the "Fields" on my report but not
> actualy report items.
> Thanks
> n

Thursday, February 16, 2012

Adding data in SQL server

This is probably a very basic question, so thanks in advance for not flaming the newbie.

I created a sample database in Access, then converted it into SQL Server format using the import/export wizard. I'm doing the "Creating a Distributed Application" walkthrough in Visual Studio and everything has compiled and runs fine. My problem is that I just created an empty database in access. It only has one table with two fields (a names table with lastName and firstName fields.) When I run the project I created in Visual Studio, I don't get any errors, but the data grid that I added doesn't have any data. This isn't surprising, because it is an empty data base. I'm very new to SQL Server and can not for the life of me figure out how to add data to a database. I feel dumb even asking such a question, but how do I create some dummy first and last names?

Thanks for the help.Use an insert statement In Query Analyser.

If your table is called names it would be something like:

INSERT Names VALUES('John', 'Smith')
INSERT Names VALUES('Jane', 'Doe')

Or you can open the table in query analyser and type the data directly into the table.

Hope this helps

Brent

Originally posted by orangewater
This is probably a very basic question, so thanks in advance for not flaming the newbie.

I created a sample database in Access, then converted it into SQL Server format using the import/export wizard. I'm doing the "Creating a Distributed Application" walkthrough in Visual Studio and everything has compiled and runs fine. My problem is that I just created an empty database in access. It only has one table with two fields (a names table with lastName and firstName fields.) When I run the project I created in Visual Studio, I don't get any errors, but the data grid that I added doesn't have any data. This isn't surprising, because it is an empty data base. I'm very new to SQL Server and can not for the life of me figure out how to add data to a database. I feel dumb even asking such a question, but how do I create some dummy first and last names?

Thanks for the help.|||Since you are familiar with MS Access you could create a link table in Access pointing to the SQL Server table and then enter data that way as well.|||OK, I'm confused. When I type in this query into the Query Analyzer:

INSERT names VALUES('John', 'Smith')
INSERT names VALUES('Jane', 'Doe')

I get the following error message:

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'names'.

The name of the database is names, the table is called name and it has firstName and lastName entities. when i click on the dbo.name table in sql server, Edit is grayed out. why is this?

why is something so common completely obfuscated in SQL server?|||Here is an example:

create table myTbl (myKey varchar(20), myValue int)
go
insert myTbl (myKey , myValue) values ('a.1.red',99)
insert myTbl (myKey , myValue) values ('a.1.blue',7)
insert myTbl (myKey , myValue) values ('a.2.red',88)
insert myTbl (myKey , myValue) values ('a.2.blue',5)
insert myTbl (myKey , myValue) values ('b.1.red',9)
insert myTbl (myKey , myValue) values ('b.1.blue',1)
insert myTbl (myKey , myValue) values ('b.2.red',8)
insert myTbl (myKey , myValue) values ('b.2.blue',6)
go|||If the table is called name then modify:

INSERT name VALUES('John', 'Smith')
INSERT name VALUES('Jane', 'Doe')

name is whatever the table is called. If your table was called contacts then it would be:

INSERT contacts VALUES('John', 'Smith')
INSERT contacts VALUES('Jane', 'Doe')

Brent

Originally posted by orangewater
OK, I'm confused. When I type in this query into the Query Analyzer:

INSERT names VALUES('John', 'Smith')
INSERT names VALUES('Jane', 'Doe')

I get the following error message:

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'names'.

The name of the database is names, the table is called name and it has firstName and lastName entities. when i click on the dbo.name table in sql server, Edit is grayed out. why is this?

why is something so common completely obfuscated in SQL server?|||OK...I figured it out. It's really easy to add data in SQL server, without adding links to an Access database or INSERT statements. All I did was navigate to the table in Enterprise Manager, right click on Open and then click "Return all rows." This pulls up an Access style representation of the data and allows you to easily enter or edit the data.

Thanks to all for your help though! Now if only I could get the update button in the web service to work....|||If you are having problems with UPDATE you should try SQL Profiler to verify the SQL statement is making it to SQL Server. If it is, then COPY/PASTE the statement from SQL Profiler into SQL Analyzer and run the SQL statement. When executing the SQL statement in Analyzer make sure you are logged in with the same UserID used for the Web to verify permissins as well.

Adding Data from a form to a database

Very basic question here but I need to add a form to a page so it adds content, its as simple as that. I've done this kind of using a <asp.Formview> tag and it works, but becuase I think I've used a form view I have to click add to insert data first. Should I be using the <asp:formview> tag or is it a problem with the templates?

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ContentID" DataSourceID="ObjectDataSource1">

<InsertItemTemplate>
Resource :<asp:DropDownList ID="ResourceIDTextBox" runat="server" Text='<%# Bind("ResourceID") %>' DataSourceID="ObjectDataSource2"
DataTextField="Resource" DataValueField="ResourceID">
</asp:DropDownList><br />
Headline:
<asp:TextBox ID="HeadlineTextBox" runat="server" Text='<%# Bind("Headline") %>' Width="451px"></asp:TextBox><br />
Date:
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'>
</asp:TextBox><br />
Body:
<FTB:FreeTextBox id="FreeTextBox1" runat="Server" Text='<%# Bind("Body") %>' Width="542px" />
<br />
ImageURL:
<asp:TextBox ID="ImageURLTextBox" runat="server" Text='<%# Bind("ImageURL") %>'>
</asp:TextBox><br />
OpeningPara:
<asp:TextBox ID="OpeningParaTextBox" runat="server" Text='<%# Bind("OpeningPara") %>'>
</asp:TextBox><br />
Ret:
<asp:TextBox ID="RetTextBox" runat="server" Text='<%# Bind("Ret") %>'>
</asp:TextBox><br />
Man:
<asp:TextBox ID="ManTextBox" runat="server" Text='<%# Bind("Man") %>'>
</asp:TextBox><br />
Pro:
<asp:TextBox ID="ProTextBox" runat="server" Text='<%# Bind("Pro") %>'>
</asp:TextBox><br />
Com:
<asp:TextBox ID="ComTextBox" runat="server" Text='<%# Bind("Com") %>'>
</asp:TextBox><br />
IndustryID:
<asp:TextBox ID="IndustryIDTextBox" runat="server" Text='<%# Bind("IndustryID") %>'>
</asp:TextBox><br />
ContentTitle:
<asp:TextBox ID="ContentTitleTextBox" runat="server" Text='<%# Bind("ContentTitle") %>'>
</asp:TextBox><br />
Status:
<asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>'>
</asp:TextBox><br />
Pub:
<asp:TextBox ID="PubTextBox" runat="server" Text='<%# Bind("Pub") %>'>
</asp:TextBox><br />
Fin:
<asp:TextBox ID="FinTextBox" runat="server" Text='<%# Bind("Fin") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate
<ItemTemplate>

<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="Click here to Add New Content">
</asp:LinkButton>
</ItemTemplate
</asp:FormView>


<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"
InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="ContentADDMethod"
TypeName="DataSet2TableAdapters.ContentADDAdapter" UpdateMethod="Update">

<DeleteParameters>
<asp:Parameter Name="Original_ContentID" Type="Int32" />
</DeleteParameters
<UpdateParameters>
<asp:Parameter Name="ResourceID" Type="Int32" />
<asp:Parameter Name="Headline" Type="String" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Body" Type="String" />
<asp:Parameter Name="ImageURL" Type="String" />
<asp:Parameter Name="OpeningPara" Type="String" />
<asp:Parameter Name="Ret" Type="String" />
<asp:Parameter Name="Man" Type="String" />
<asp:Parameter Name="Pro" Type="String" />
<asp:Parameter Name="Com" Type="String" />
<asp:Parameter Name="IndustryID" Type="Int32" />
<asp:Parameter Name="ContentTitle" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="Pub" Type="String" />
<asp:Parameter Name="Fin" Type="String" />
<asp:Parameter Name="Original_ContentID" Type="Int32" />
<asp:Parameter Name="ContentID" Type="Int32" />
</UpdateParameters
<InsertParameters>
<asp:Parameter Name="ResourceID" Type="Int32" />
<asp:Parameter Name="Headline" Type="String" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Body" Type="String" />
<asp:Parameter Name="ImageURL" Type="String" />
<asp:Parameter Name="OpeningPara" Type="String" />
<asp:Parameter Name="Ret" Type="String" />
<asp:Parameter Name="Man" Type="String" />
<asp:Parameter Name="Pro" Type="String" />
<asp:Parameter Name="Com" Type="String" />
<asp:Parameter Name="IndustryID" Type="Int32" />
<asp:Parameter Name="ContentTitle" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="Pub" Type="String" />
<asp:Parameter Name="Fin" Type="String" />
</InsertParameters
</asp:ObjectDataSource>


<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataSet2TableAdapters.ResourcesTableAdapter">
<InsertParameters>
<asp:Parameter Name="Resource" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>

I'm sorry, but what is your complaint? You have to click an add button in order to add a new record?

Sunday, February 12, 2012

Adding an image to details view

I'm some what of a noob when it comes to ASP.NET 2.0 and SQL Server 2005 Express editions, so please bare with me.

I have created a basic database that is only one table. One of the fields is LogPicture with type of image.

I just want to go into the table and manually place a picture in the table, but it seems like I can not get the format down. I have tried including the picture I want into the project, but no dice. I've also tried putting the physical pathname (on the harddrive) and the web address of this field in there. Suggestions please?

ss*bump*

I am basically just looking for the syntax of how an image is inserted. Anyone..... please?|||

Image data is stored as binary stream in SQL Server. You can either use bcp.exe utility to insert BLOB data (image/text/ntext) or write your own code to input binary stream to the column. You can take a look at this post:

http://forums.asp.net/thread/1257487.aspx

And here is a article that introduces bcp utility:

http://msdn2.microsoft.com/en-us/library/ms162802.aspx