Create A Database Table With SqlDataSource?

Jan 18, 2008

I want to create a table in a SQL-database, and I'm wondering how to do it in Visual Studio 2005. Is it possible to create a table using an SQL-query in the SqlDataSource wizard?

Or, in general... what would be the best way to create a database table from VS2005?

View 4 Replies


ADVERTISEMENT

Boolean: {[If [table With This Name] Already Exists In [this Sql Database] Then [ Don't Create Another One] Else [create It And Populate It With These Values]}

May 20, 2008

the subject pretty much says it all, I want to be able to do the following in in VB.net code):
 
{[If [table with this name] already exists [in this sql database] then [ don't create another one] else [create it and populate it with these values]}
 
How would I do this?

View 3 Replies View Related

Dynamic Create Table, Create Index Based Upon A Given Database

Jul 20, 2005

Can I dynamically (from a stored procedure) generatea create table script of all tables in a given database (with defaults etc)a create view script of all viewsa create function script of all functionsa create index script of all indexes.(The result will be 4 scripts)Arno de Jong,The Netherlands.

View 1 Replies View Related

Can CREATE DATABASE Or CREATE TABLE Be Wrapped In Transactions?

Jul 20, 2005

I have some code that dynamically creates a database (name is @FullName) andthen creates a table within that database. Is it possible to wrap thesethings into a transaction such that if any one of the following fails, thedatabase "creation" is rolledback. Otherwise, I would try deleting on errordetection, but it could get messy.IF @Error = 0BEGINSET @ExecString = 'CREATE DATABASE ' + @FullNameEXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'CREATE TABLE ' + @FullName + '.[dbo].[Image] ( [ID][int] IDENTITY (1, 1) NOT NULL, [Blob] [image] NULL , [DateAdded] [datetime]NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'ALTER TABLE ' + @FullName + '.[dbo].[Image] WITHNOCHECK ADD CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED ( [ID] ) ON[PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorEND

View 2 Replies View Related

Create An Extra Table (for Audit Purpose) For Every Existing Table In A Database

Mar 28, 2008

Hi all, please help. I m trying to create an "empty" table from existing table for the audit trigger purpose.
For now, i am trying to create an empty audit table for every table in a database named "pubs", and it's seem won't work.
Please advise.. Thanks in advance.

Here is my code:





Code Snippet

USE pubs

DECLARE @TABLE_NAME sysname
DECLARE @AUDIT_TABLE VARCHAR(50)

SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE= 'BASE TABLE'
AND TABLE_NAME NOT LIKE 'audit%'
AND TABLE_NAME!= 'sysdiagrams'
AND TABLE_NAME!= 'Audit'
AND TABLE_NAME = 'sales'

WHILE @TABLE_NAME IS NOT NULL
BEGIN

SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME> @TABLE_NAME
AND TABLE_NAME = 'sales'

SELECT @AUDIT_TABLE = 'Audit'+''@TABLE_NAME''


SELECT * INTO @AUDIT_TABLE
FROM @TABLE_NAME

TRUNCATE TABLE @AUDIT_TABLE
ALTER TABLE @AUDIT_TABLE ADD UserAction Char(10),AuditStartTime Char(50),AuditUser Char(50)


SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME> @TABLE_NAME
AND TABLE_TYPE= 'BASE TABLE'
AND TABLE_NAME!= 'sysdiagrams'
AND TABLE_NAME!= 'Audit'
AND TABLE_NAME NOT LIKE 'audit%'

END
Thanks. ..

View 6 Replies View Related

Need Help To Create This Table In My Database

Jan 1, 2008

I create a database which has the following tables:
1.      Supplier
2.      Item:
3.      Store:4.      Item Stored:5.      Invoice:6.      Invoice Lines:7.      Recite: 8.      Recite Lines:9.      Client:where the Supplier table has the following field:·         Code: contains of  3 characters and 6 auto increment numbers (example: "DLL -  123456") (PK)·         First Name: string of 30 character it could be Arabic or English·         Middle Name: string of 30 character it could be Arabic or English·         Last Name: string of 30 character it could be Arabic or English·         First Contact Date: states the date of the first contact·         Last Contact Date: states the last date of contact (updated after any goods sold by this supplier to us)·         Phone: Phone number of this supplier·         Address: 200 character also could be in Arabic or English·         Rank: default = 0(number of Buying Transactions from that supplier)states its rank (the more goods we buy from the higher the rank)  and the Invoice table has the following fields:·         Code: contains of  3 characters and 6 auto increment numbers (example: "DLL -  123456") (PK)·         Date: date of insuring that invoice·         Shipment Date: the date suppose the items ordered arrival·         Type: Buying or Sellingo   If Buying the user must select Suppliero   If Selling the user must select Client·         Supplier Code: incase Type is Buying it shouldn't allow null else it allows null, Code (FK) from  table Supplier·         Client Code: incase Type is Selling it shouldn't allow null else it allows null, Code (FK) from table Client
 
Now i want to create this database with it's tables
i just want to know the data type for each both tables supplier and invoice tables
Thanks

View 2 Replies View Related

How To Create A Table In A New Database

Sep 14, 2007

Hi guys

I just installed SQL Server 2005 / developer and I only want to create a new table but I cannot find where to do it

The only thing I have when I start the application is "Configuaration tools"

does anybody help to just start?

Thank you
Magda



Magda

View 7 Replies View Related

SDF Database - Create Table Error

Jan 22, 2007

Hi,

I have connected sdf database through SQL server management studio.

I want to execute a simple query as,

CREATE TABLE [dbo].[user]( [user_id] [int] NOT NULL)

While executing the same through Query pane, it gives error as,

<>

Major Error 0x80040E14, Minor Error 26100

> CREATE TABLE [dbo].[user]( [user_id] [int] NOT NULL)

The table name is not valid. [ Token line number (if known) = 1,Token line offset (if known) = 22,Table name = user ]

<>

Any pointers?

 

Thanks,

Shailesh.

View 5 Replies View Related

Cant Create New Database / CREATE DATABASE Permission Denied In Database Master (error 262)

Oct 2, 2007

 
 I am using SQL express and Visual web developer on windows Vista.
When I try to create a new database the following message appears.
 
CREATE DATABASE permission denied in database master (error 262)
I log on to my computer as an administrator.
Help appreciated
 Prontonet
 
 
 

View 4 Replies View Related

CREATE TABLE In Wrong Database (Master)

Apr 19, 2006

I am using ASP.NET 1.1 and  MS SQL 2005 the folowing ODBC stringconnection
Driver={SQL Server};Server=(local);MyBase;Uid=;Pwd=;Trusted_Co nnection=;

when trying to CREATE a TABLE (with vb.net code) I get an error because the TABLE are written in Master !! and not in MyBase

I am using windows Authentication

what can be wrong ?

thank you

View 6 Replies View Related

CREATE TABLE In Wrong Database (Master)

Apr 19, 2006

I am using ASP.NET and a normal ODBC stringconnectionDriver={SQL Server};Server=(local);MyBase;Uid=;Pwd=;Trusted_Co nnection=;when trying to CREATE a TABLE (with vb.net code) I get an error because the TABLE are written in Master !! and not in MyBasei am using windows authenticationwhat can be wrong ?thank you

View 13 Replies View Related

Not Able To Create An Identity Column For An Existing Database Table

Feb 1, 2008

I am working with a table in SQL server. I have a column that I want to designateas an identity column. I am not able to do this, because the field for "Identity Specification" is not editiable.
What I did was I went to sql server, right clicked and selected "Modify".The column properties dialog box/edit grid is then displayed with attributesthat I can modify.
There are two major nodes in this dialog box. One is named "General" and the otheris named "Table Designer". I expand the "Table Designer" node and then go to the node labeled "Identity Specification" It is here where I would like to edit thevalues.
The values that are listed for edit are listed below. BUT, the problem is thatI can place my cursor in those fields, but I am not able to change/edit them.Can anyone tell me what the problem is here? and how I can fix it?
 +Identity Specification   (Is Identity)   Identity Increment   Identity Seed

View 3 Replies View Related

Simply Create A Table In A MsSQL Express Database Through ADO.net

May 27, 2008

Hello there,Now I'm really down, how do I simply create a Table in a database?It must be something likeCreate Table TableName
(
column_name data_type
)
But first how do I execute that string, so it create the table..And if we get that far, how do you then set a table to primarykey?
Hope really for help, because this is a importen thing, and I cant find the answer? :S

View 4 Replies View Related

Create List Of Table Names And Size For A Database

May 5, 2004

Hi there,

I am trying to create a list of all the tables in one database and then list the size of each table. So for example I want to create a table with the table name and table size for one DB

E.g

Table1 1111KB
Table2 123300MB
Table3 120448KB

etc for all the tables in a particukar DB

I know there is a stored procedure to list the sizes: 'sp_spaceused' but not sure how to script all this together.

can anyone help please!!

From

NewToSQL

View 12 Replies View Related

How To Create CLR Table Trigger In Server Database Project

Jul 7, 2015

It used to be so simple in SQL 2008.

With SSDT and VS2012, it seems impossible. 

I created the project and I added a trigger

public
partialclassTrigger
{
    [Microsoft.SqlServer.Server.
SqlTrigger(Name =
"myPM10000", Target
= "[dbo].[PM10000]",
Event = "FOR UPDATE, INSERT")]
publicstaticvoidmyPM10000()
etc.

When I try to build the project it fails:

Error 1 SQL71561: Trigger: [dbo].[myPM10000] has an unresolved reference to object [dbo].[PM10000]. D:ProjectsVS2013myproject_CLRobjDebugmyproject_CLR.generated.sql 8 32 myproject_CLR

I have tried with and without adding a database reference.  With the reference all I accomplish is lost time waiting for that monster link to the database to generate. There has to be a way to make this happen, right?  I don't want to have to rewrite this in Transact SQL.

View 8 Replies View Related

Create Temp Table To Store Data From Database(mssql)

Jun 26, 2007

I am a starter of vb.net and trying to build a web application. Do anyone know how to create a temp table to store data from database? I need to extract data from 3 different tables (Profile,Family,Quali). Therefore, i need to use 3 different queries to extract from the 3 tables and then store it in the temp table. Then, i need to output the data from temp table to the screen. Do anyone can help me?

View 2 Replies View Related

Create A Custom Webpage To Edit/update A Table In A SQL Database.

Aug 25, 2007

Hi everyone, this is is my first post, so please reply and help.
I'm working on a project right now that uses asp 2.0 and SQL server 2005 express edition. This is a general idea of the project. In our company some of us receive ECO notifications (engineering change orders) for our products and we need to implement these to the test scripts that are on the production floor.  So the project is about entering the new ECO into a database which will send an automatic notification to our test team. When they receive the notification they will have to sign in to the website and introduce their login and password to sign off the ECO (Following some checkpoints already defined by me, for example, Area ready, Test script modification necessary, new firmware introduction, comments, etc...) but I also need to record WHO and WHEN sign that ECO. We have 3 different test areas in our factory: Electrical, Functional and Systems, so all THREE areas must be signed off in order to the ECO go to a IMPLEMENTED state (at this point i need to send a new email saying that the eco has been implemented in all three areas).
 So far I've completed the following things:
-users validation (logins, areas)
-New custom entry form for the ECOs and automatic email notification (part of what I did is described below). Dim ECODataSource As New SqlDataSource()ECODataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ECO_ICSConnectionString1").ToString()
 
ECODataSource.InsertCommandType = SqlDataSourceCommandType.StoredProcedure
ECODataSource.InsertCommand = "EcoNew"
 ECODataSource.InsertParameters.Add("EcoNumber", EcoNumberTextBox.Text)
ECODataSource.InsertParameters.Add("EcoDescription", EcoDescriptionTextBox.Text)
ECODataSource.InsertParameters.Add("EcoMandatory", EcoMandatoryDropDownList.Text)
 -Depending on which test area is the the engineering from, I can filter the ECOs and just shows the ones that their test area is pending. (using GridView)
But I'm stuck right now when the engineers have to sign the ECO for their test areas. I was able to use the Gridview and DetailsView to EDIT most of the things that I need. But there are somethings that I don't like:
1. When using the EDIT option on Gridview or Detailsview, all fields can be edited including ECO number, description and mandatory, which I don't want them to change. If I set those columns to read only, when editing that row again. It gives me an error that says that the ECOnumber can't be  NULL, but if I remove these 3 columns the Engineer will not know which ECO they have sign. They are only going to be able to see the EcoId, which doesn't say much.
2. Also I saw that I wasn't able to do is to enter the USER login and CURRENT system date and time automatically. I don't want them to manually enter the date and their login manually.
3. Finally, when the last area signs the ECO, I want to update that record and set a flag that tells me that the ECO has been completed.
 So what I really want is to create some sort of form (textboxes, labels, checkboxes, etc.) that will UPDATE the selected ECO from the gridview for instance. So when I select the row from the GridView, It will show the data (Econumber, description and mandatory as READ ONLY) and use the rest of the things as INPUT for the engineer to complete. At the end an "update button" and when I click it, It will enter/update the data on that specific row, but including the time and user login as well.
Also to check if the other 2 areas have signed and if so, change the ECOReadiness flag to 1 and send the email.
Is there a code like the one I used above to do this ? Or if you think there a better way to do this, I'll be very glad to hear it.
 I'm new using sql and asp, so If i'm asking some dumb questions please forgive me. .
 
Here's my table definition for your reference:
EcoId - primary key.
EcoNumber
EcoDescription
EcoMandatory
EcoReadiness   <- Flag for the entire ECO, when ALL 3 areas have signed, this will be 1.
ATE < - Flag for Electrical area.
ATEscripts < - Just a Yes/no input.
ATEengineer <- user login
ATEdatetimestamp <- Date.Now()
FAT < - Flag for functional.
FATscripts
FATengineer
FATdatetimestamp
SYSTEMS < - Flag for systems.
SYSTEMSscripts
SYSTEMSengineer
SYSTEMSdatetimestamp
 
THANKS IN ADVANCE,
Regards,
Jesus

View 2 Replies View Related

Sqldatasource Replicating On Insert On A Create User Wizard

Apr 18, 2007

I have a create user wizard.  On the created user event.  I am calling a datasource.insert to insert the email, userid, and opt in to newsletter option into another table.
 For some reason it is inserting the value twice into the database.  I have checked possibilities for why this might be happening.  I am pulling my hair out. 
 Any ideas?
Andrew

View 7 Replies View Related

Using The SqlDataSource.SelectCommand To Create Parameterized SQL Statements - Search Box

Sep 18, 2007

Although writing a parameterized SQL statement has been simplified using the asp:parameter options, it still may benefit to use the old fashioned method of writing a sql statement using an input string. I have noticed this for wanting to make a parameter to select which table I want to pull from. Here is some code I wrote to pull information from a database based on input from a search box and write it to a gridview.
Partial Class Private_SearchResultsInherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Table As String
Dim SearchString As StringSearchString = Request.QueryString("SearchString")
Table = Request.QueryString("Table")
If Len(Trim(SearchString)) > 0 ThenSelect Case Table
Case "Plant"
SqlDataSource1.SelectCommand = "SELECT PlantName as 'Plant',PlantAddr as 'Address',PlantCity as 'City',PlantState as 'State',PlantCountry as 'Country',PlantZip as 'ZIP' FROM Plant WHERE PlantName LIKE '%" & SearchString & "%' OR PlantCity LIKE '%" & SearchString & "%' OR PlantState LIKE '%" & SearchString & "%' OR PlantCountry LIKE '%" & SearchString & "%' OR PlantZip LIKE '%" & SearchString & "%' ORDER BY PlantName"
Case "Contacts"
SqlDataSource1.SelectCommand = "SELECT ContactPosition as'Position',ContactTitle as 'Title',ContactLast as 'Last Name',ContactFirst as 'First Name',ContactPhone as 'Phone No' FROM Contacts WHERE ContactLast LIKE '%" & SearchString & "%' OR ContactFirst LIKE '%" & SearchString & "%' OR ContactPosition LIKE '%" & SearchString & "%' OR ContactPhone LIKE '%" & SearchString & "%' OR ContactTitle LIKE '%" & SearchString & "%' ORDER BY ContactLast"
Case "Events"
SqlDataSource1.SelectCommand = "SELECT EventName as 'Event',CONVERT(varchar,EventStartDate,101) as'Start Date',CONVERT(varchar,EventEndDate,101) as 'End Date',EventNotes as 'Notes',EventNoAttendees as 'Attendees',EventType as 'Event Type' FROM Events WHERE EventName LIKE '%" & SearchString & "%' OR EventStartDate LIKE '%" & SearchString & "%' OR EventEndDate LIKE '%" & SearchString & "%' OR EventNotes LIKE '%" & SearchString & "%' OR EventNoAttendees LIKE '%" & SearchString & "%' OR EventType LIKE '%" & SearchString & "%' ORDER BY EventName"
Case ""
Label1.Text = "Nothing Selected in Drop Down Box"
End Select
Else
Label1.Text = "No Search Parameters Entered"
End If
GridView1.DataBind()End Sub
End Class
 
Here is also my code to the front end of the page...
 
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="SearchResults.aspx.vb" Inherits="Private_SearchResults" title="Search Results" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<strong><span style="font-family: Tahoma">Search Results<br />
<br /></span></strong>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:Label ID="Label1" runat="server" Font-Names="Tahoma" Font-Size="10pt"></asp:Label><br />
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" DataSourceID="SqlDataSource1" Width="1020px">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" Font-Names="tahoma" Font-Size="Small" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="Indigo" Font-Bold="True" ForeColor="White" Font-Names="tahoma" Font-Size="Small" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" /></asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CRMConnectionString %>"></asp:SqlDataSource>
</asp:Content>
 

View 2 Replies View Related

Create Table From Text File, Extract Data, Create New Table From Extracted Data....

May 3, 2004

Hello all,

Please help....

I have a text file which needs to be created into a table (let's call it DataFile table). For now I'm just doing the manual DTS to import the txt into SQL server to create the table, which works. But here's my problem....

I need to extract data from DataFile table, here's my query:

select * from dbo.DataFile
where DF_SC_Case_Nbr not like '0000%';

Then I need to create a new table for the extracted data, let's call it ExtractedDataFile. But I don't know how to create a new table and insert the data I selected above into the new one.

Also, can the extraction and the creation of new table be done in just one stored procedure? or is there any other way of doing all this (including the importation of the text file)?

Any help would be highly appreciated.

Thanks in advance.

View 3 Replies View Related

Problems On Create Proc Includes Granting Create Table Or View Perissinin SP

Aug 4, 2004

Hi All,

I'm trying to create a proc for granting permission for developer, but I tried many times, still couldn't get successful, someone can help me? The original statement is:

Create PROC dbo.GrantPermission
@user1 varchar(50)

as

Grant create table to @user1
go

Grant create view to @user1
go

Grant create Procedure to @user1
Go



Thanks Guys.

View 14 Replies View Related

Create Script To Create/Refresh Identical Database

Mar 26, 2008



I'm new to using SSIS and have been reading and learning slowly how to use it. I'm trying to create an identical copy of our database for reporting. I've used the Import/Export wizard, but have had some issues with foreign keys and with sql_variant columns.

I've tried searching for anything but haven't had any luck as of yet. I guess I don't even know where to start or what to look for.

Any help would be appreciated. Thanks!

View 9 Replies View Related

Default Table Owner Using CREATE TABLE, INSERT, SELECT && DROP TABLE

Nov 21, 2006

For reasons that are not relevant (though I explain them below *), Iwant, for all my users whatever privelige level, an SP which createsand inserts into a temporary table and then another SP which reads anddrops the same temporary table.My users are not able to create dbo tables (eg dbo.tblTest), but arepermitted to create tables under their own user (eg MyUser.tblTest). Ihave found that I can achieve my aim by using code like this . . .SET @SQL = 'CREATE TABLE ' + @MyUserName + '.' + 'tblTest(tstIDDATETIME)'EXEC (@SQL)SET @SQL = 'INSERT INTO ' + @MyUserName + '.' + 'tblTest(tstID) VALUES(GETDATE())'EXEC (@SQL)This becomes exceptionally cumbersome for the complex INSERT & SELECTcode. I'm looking for a simpler way.Simplified down, I am looking for something like this . . .CREATE PROCEDURE dbo.TestInsert ASCREATE TABLE tblTest(tstID DATETIME)INSERT INTO tblTest(tstID) VALUES(GETDATE())GOCREATE PROCEDURE dbo.TestSelect ASSELECT * FROM tblTestDROP TABLE tblTestIn the above example, if the SPs are owned by dbo (as above), CREATETABLE & DROP TABLE use MyUser.tblTest while INSERT & SELECT usedbo.tblTest.If the SPs are owned by the user (eg MyUser.TestInsert), it workscorrectly (MyUser.tblTest is used throughout) but I would have to havea pair of SPs for each user.* I have MS Access ADP front end linked to a SQL Server database. Forreports with complex datasets, it times out. Therefore it suit mypurposes to create a temporary table first and then to open the reportbased on that temporary table.

View 6 Replies View Related

What Is The Difference Between: A Table Create Using Table Variable And Using # Temporary Table In Stored Procedure

Aug 29, 2007

which is more efficient...which takes less memory...how is the memory allocation done for both the types.

View 1 Replies View Related

How To Create A Update Button To Update Two SqlDataSource Controls?

May 10, 2006

I want to update two tables in one page. So I created two FormView bound on two SqlDataSource controls, and I create a Update button on the bottom of page. And I writen some codes as below:
btnUpate_Click(object sender, EventArgs e){
   sqlDataSource1.Update();
   sqlDateSource2.Update();}
But, the records haven't updated.
In SqlDataSource2_Updating() function, I found all the parameters is null.
So, how to modify my code to do it.
 
Zhang

View 2 Replies View Related

How To Use &<asp:SqlDataSource&> With Ole Database

Apr 24, 2008

Hi all,
I used to use <asp:SqlDataSource as a data suorce to my gridviews in the client side, but now I'm using access database.
Is there any way to use the same feauter with Ole Database connection, this is a sample from my <asp:SqlDataSource:
<asp:GridView ID="OrderGridView" runat="server" AutoGenerateColumns="False" DataSourceID="OrderSqlDataSource">
<asp:SqlDataSource ID="OrderPrintSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:iainternetConnectionString %>"        SelectCommand="SELECT * FROM @tblOrder">         <SelectParameters>            <asp:QueryStringParameter Name="tblOrder" QueryStringField="tbl" />        </SelectParameters>    </asp:SqlDataSource>
any ideas to solve this. thanks.

View 5 Replies View Related

SqlDataSource Won't Update Table

Feb 8, 2008

I have a number of textboxes in a WizardStep of my CreateUserWizard and I can't update the contents to the database (see below for an example). Any suggestions would be appreciated. Dim txt As TextBox = cuwMoreInfo.FindControl("txtAddress")
srcMoreInfo.UpdateParameters("Address").DefaultValue = DirectCast(txt, TextBox).Text 

View 12 Replies View Related

How To Access More Than One Database In SQLDataSource

Apr 25, 2007

Hello,
 Is it possible to access both my database and the ASPNETDB within the same SQLDATASOURCE using SQL Express ?
I want to pull out some user details from the aspnet_* tables within the ASPNETDB
In my database I have created the 'UserId' fields so the relevant joins can take place.
In my web.config:
<connectionStrings>
<add name="mydb" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|mydb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>
 In my asp (showing only mydb):
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:mydb %>"
SelectCommand="SELECT [CreateDtTime], [UserId], [Comment] FROM [Log_Dtl] WHERE ([LogId] = @LogId)">
<SelectParameters>
<asp:QueryStringParameter Name="LogId" QueryStringField="LogId" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
 
Any help would be appreciated.
Thank you
Lee

View 1 Replies View Related

SqlDataSource Using A Type Parameter Of Table

Oct 8, 2006

I am not sure (and I've been known to overlook things) if it is possible to use a Table parameter type as parameter to a stored procedure?  Is it possible? I would prefer not to create a SQL batch statement calling an stored proc w/ one parameter over and over. Instead i'd rather just create the stored proc to take a table parameter and pass the table into the stored proc.  I know I could use a CSV string of IDs instead of a table...  or I could create a big SQL batch and use that.  But I'd rather not. Could anyone provide some guidance? Thanks!Joe

View 2 Replies View Related

Session Var As Table Name In SQLDataSource Selectcommand?

Mar 12, 2008

Hi Everyone,
I set the session("MyTable") with the user's name as contents when the user logs in, then I copy a new table name with session("MyTable") , I set PK and this all works, but I can't seem to figure out how to use the session var as table name SQLDataSource Selectcommand? I try a bunch of different stuff, putting it into a key in the web.config. Seems like this should be a piece of cake.
Im getting ~ "Session variable is not a valid datasource item" etc. Below is one of the things I have tried.<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connectio String %>" SelectCommand="Select * From [" + Session("MyTable") + "] Where ID = @ID">
 TIA
Cebo

View 2 Replies View Related

SqlDataSource Select From One Table And Insert To Another

Mar 13, 2008

Is it possible within a Sqldatasource to select data from one database table and the insert that data into another?
eg:
 1 <asp:SqlDataSource ID="SqlDataSource" runat="server"
2 ConnectionString="<% Something %>"
3 InsertCommand="INSERT INTO [Resumes] ([ResumeID], [UserID], [CompanyID], [ResumeTitle], [ResumeDesc]) VALUES (@ResumeID, @UserID, @CompanyID, @ResumeTitle, @ResumeDesc)"
4 SelectCommand="SELECT [UserId], [CompanyID], [CompanyName] FROM [Info] WHERE ([UserId] = @UserId)" <SelectParameters>
5 <skm:MembershipUserIdParameter Name="UserId" />
7 </SelectParameters>
8 <InsertParameters>
9 <skm:MembershipUserIdParameter Name="UserId" />
10 <asp:Parameter Name="CompanyID" Type="Int32" />
11 <asp:Parameter Name="ResumeTitle" Type="String" />
12 <asp:Parameter Name="ResumeDesc" Type="String" />
13 </InsertParameters>
14 </asp:SqlDataSource>
  

View 1 Replies View Related

Sqldatasource Select Table By Year

Apr 29, 2008

Hello,
I am trying to write a select command that will select a table by year using asp:sqldatasource selectcommand.  The table name includes the year, ie: table98, table99, table00, table01, etc.  These tables do not have a 'year' field but there is a separate table called "Years" where each record is a different year.  In other words, my select statement is static where is needs to be dynamic.  Not sure if that makes sense, but any help would be great!!!

View 1 Replies View Related

How Do I Retrieve The IDENT_CURRENT Value Of A Table Using An SqlDataSource?

Dec 8, 2005

Hi
I am trying to get the last ID value of a table. 
The following code worked when a SQLConnection object was used, how do I achieve the same result using an SQLDataSource?
this.sqlSelectCmd2 = new System.Data.SqlClient.SqlCommand("SELECT IDENT_CURRENT('Assets')",sqlConnection1);
sqlConnection1.Open();
int nID = Convert.ToInt32( this.sqlSelectCmd2.ExecuteScalar() ) ;
nID++;
dc.FocusedRow["ID"] = nID.ToString();
Cheers
Pen
 

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved