Now, I don't know if what I want to do is possible, but here goes. In the table I want to query, there is an "approval status" column, of type Int32. There are four approval levels, 1, 2, 3 and 4. What I want to set up is a query in the table adapter that can return all entries of one or more approval levels. In "raw" sql, I would do something like:
SELECT * FROM facility_table WHERE (approved IN (1,2,3));
What I want to do though, is to have the list of approval codes to be a parameter that I can pass to the table adapter query, so the where clause becomes "WHERE (approved IN (@approval))", and I pass a string with the list of approval codes. But the query designer doesn't want to cooperate with me, as it insists that "@approval" should be an int32.
Any suggestions?
Hi All, I would like to send a query via Table adapter using parameter that is not the whole field. (Its only a part of the filed).
I will try to illustrate my needs: We have a list of items in a data grid. I would like to get the list of items who are answering my item name search query. (I need to change the list every time the user enter another key letter for the search).
I would like to do so in the data adapter, but I'm not able to use the LIKE statement.
Please please try to help me
P.S. Do I need to use stored procedure, if so, can anyone give me an idea how to do so ?
I'm looking for a way to pass an array of values as a parameter to a query in a table adapter. For example I want to run a query something like:SELECT * FROM menu WHERE menu_role IN (@roles)And I could pass something like 'RegisteredUser, SuperUser, OtherUser' to the @roles parameter.For some reason I can't figure out a way to do this. Any help would be greatly appericated.Thanks,Ryan.
Hi All, I have two tables.First is CAT_TABLE_LIST ;FIELD_NAME OPPOSITE_NAME TBL_NAMEHeight (mm) COL_1 TBL_13Cylinder volume (cm³) COL_5 TBL_13Torgue (daN.m) COL_7 TBL_13Cylinder weight(kg) COL_13 TBL_13Pump Type COL_9 TBL_13Fuel Consumption Col_22 TBL_22Color Col_41 TBL_09--------------------------------------------------------------------Second is TBL_13 (there are a few tables for each distict value for CAT_TABLE_LIST.TBL_NAME column );STOCK_CODE COL_1 COL_5 COL_7 COL_13 COL_9FC-25 12,5 5 15.000 45 DP 75FT-45 27 9 40.000 35 DP 101--------------------------------------------------------------------the CAT_TABLE_LIST.TBL_NAME holds relevant table name and CAT_TABLE_LIST.OPPOSITE_NAME holds columns names of that relavant table.The issue is, the columns of relevant tables dynamicly created. I mean if i insert new row to CAT_TABLE_LIST like that;INSERT INTO CAT_TABLE_LIST ('Size(USA)','Col_77','TBL_13')the new column will created for TBL_13 ;ALTER TABLE TBL_13 ADD Col_77 VARCHAR(200)And if i delete a row from CAT_TABLE_LIST, in the same transaction the column will droped from relevant table, as followsDELETE CAT_TABLE_LIST WHERE TBL_NAME ='TBL_13' AND OPPOSITE_NAME='Col_77'goALTER TABLE TBL_13 DROP COLUMN Col_77-------- Expected select query result is (for TBL_NAME = 'TBL_13' AND STOCK_CODE ='FC-25' ) .....STOCK_CODE OPPOSITE_NAME FIELD_NAME VALUEFC-25 COL_1 Height (mm) 12,5FC-25 COL_5 Cylinder volume (cm³) 5FC-25 COL_7 Torgue (daN.m) 15.000FC-25 COL_13 Cylinder weight(kg) 45FC-25 COL_9 Pump Type DP 75------------------------------------------------------------------------------How can i get this result ? Thanks in advance...
I built a very simple report which uses a query to define the options in the parameter€™s dropdown. I used that same dataset to define the default for that parameter (meaning that it will just pick the first row from the dataset and use that as the default). When I run the report watching a Profiler trace on the SQL database, it runs that query twice. (Presumably, that€™s once to fill the dropdown list and once to figure out the default.) That seems silly to me since it is the same query that is the same dataset in Reporting Services. Is there any way around this? My parameter bar is rendering twice as slowly as it should be.
I've tested against SSRS 2005 SP1 and the CTP of SP2.
I'm using an ObjectDataSource in Visual Studio to retrieve records from a SQL Server 2005 database. I have a very simple dilemma. In a table I have fields FirstName, Surname, Address1, Address2, Address3 etc. None of these are mandatory fields. It is quite common for the user not to enter data in Address2, Address3, so the values are <null> in the SQL table. In Visual Studio 2005 I have an aspx form where users can pass search parameters to the ObjectDataSource and the results are returned according to the passed in parameters. The WHERE clause in my Table Adapter is:WHERE (Address1 LIKE @Address1 + '%') AND (Address2 LIKE @Address2 + '%') AND (Address3 LIKE @Address3 + '%') AND (FirstName LIKE @FirstName + '%') AND (Surname LIKE @Surname + '%') If, for example, I simply want to search WHERE FirstName LIKE ‘R’, this does not return any results if the value of Address3 is <null> My query is this: Could someone please show me the best way in Visual Studio 2005 to return records even if one of the Address fields is <null>. For reference, I have tried: Address3 LIKE @Address3 + '%' OR IS NULLThis does work, however itsimply returns every instance where Address3 is <null> (accounting for about 95% of the records in the database). Thanks in advance Simon
But now I am getting error "General Network Error. Check your network documentation" after specifying Use existing stored procedure in TableAdpater Configuration Wizard.
ALTER PROCEDURE dbo.Insert_MailSignature( @Singnature image )
AS
SET NOCOUNT OFF;
INSERT INTO MailsSignature (Singnature) VALUES (@Singnature);
SELECT Id, Singnature FROM MailsSignature WHERE (Id = SCOPE_IDENTITY())
For testing I created a desktop application and found that the same Code, same(Use existing stored procedure in TableAdpater Configuration Wizard) and same stored procedure is working fine in inserting image into the table.
Can someone tell me why I an getting the following error message for my table adapter: "incorrect syntax near '?'" The selecte statement is below. SELECT Questions.QuestionID, Questions.QuestionNumber, Questions.QuestionText, Questions.SampleAnswer, SAFSection.SectionNumber + ' - ' + SAFSection.SectionName as [Section], SAFSubSection.SubSectionNumber + ' - ' + SAFSubSection.SubSectionName as [SubSection], SAFSubSection.SubSectionDefinition, SAFSubSection.SubSectionQuestion, SAFSubSection.SubSectionInstruction, Answers.AnswerFROM (SAFSubSection INNER JOIN (SAFSection INNER JOIN Questions ON SAFSection.[SectionID] = Questions.[QuestionSectionID]) ON SAFSubSection.[SubSectionID] = Questions.[QuestionSubSectionID]) LEFT JOIN Answers ON Questions.QuestionID = Answers.QuestionIDWHERE Answers.SystemID = ?Order BY SAFSection.SectionID, SAFSubSection.SubSectionID,Questions.QuestionID
I am a beginner with Report Designer (and with Reporting Services). Following the tutorials 'Adding parameters to filter Reports ...' I tried using the @symbol to add a parameter to my query: where code = @code_value...I get the error: ORA -000936 missing expression (msorlib) Is there another syntax that I should use to define a parameter/variable in query for my oracle dataset?
Hello, I have a table adapter which uses a Query string to get the select view and a stored procedure for its delete portion. Not all of the columns in the select statement are required for the stored procedure. When I try to do the delete, it attempts at passing in more variables than it needs and ends up resulting in an error saying it can't find a procedure that is valid. Is there any way to restrict which columns are being passed? Thanks, Chris
I have an application (ASP.NET 2.0/SQL Server 2005) which makes heavy use of table adapters for pulling records from SQL. Under heavy load, we get a lot of SQL Server Timeout errors. We have run a trace on SQL Server and it shows that several of the SQL statements being passed into SQL Server, from the Table Adapters, have bad SQL.
For example, here is the SQL in one of the table adapters
SELECT HomeMsgID, messageName, messageHTML, messageText, populationID FROM MyUCR_HomeMessages WHERE (populationID IN (SELECT populationID FROM MyUCR_Population_CPID AS MyUCR_Population_CPID_1 WHERE (CPID = @CPID))) AND (isVisible = 1) AND (showDate <= @showDate) AND (removeDate >= @removeDate)
myUCR_HomePageMsgsTableAdapters.MyUCR_HomeMessagesTableAdapter ta = new myUCR_HomePageMsgsTableAdapters.MyUCR_HomeMessagesTableAdapter(); myUCR_HomePageMsgs.MyUCR_HomeMessagesDataTable dt = new myUCR_HomePageMsgs.MyUCR_HomeMessagesDataTable();
ta.FillByCPID(dt, showDate, removeDate, CPID);
What the SQL trace shows, when it fails, is this (notice the extra single quotes around the showDate, removeDate parameters): E000 exec sp_executesql N'SELECT HomeMsgID, messageName, messageHTML, messageText, populationID FROM MyUCR_HomeMessages WHERE (populationID IN (SELECT populationID FROM MyUCR_Population_CPID AS MyUCR_Population_CPID_1 WHERE (CPID = @CPID))) AND (isVisible = 1) AND (showDate <= @showDate) AND (removeDate >= @removeDate)',N'@showDate datetime,@removeDate datetime,@CPID int',@showDate=''2007-02-05 00:00:00:000'',@removeDate=''2007-02-05 00:00:00:000'',@CPID=3071225 1[Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '2007'.
I recreated the SQL to use a stored procedure, and got a similar error:
I have an SP that I call via table adapter. If I do not pass a value in the string field ('eventRef'), the SP never gets called - it appears that the table adapter is filtering it...? I need to be able to count records that have an 'eventRef' = to the one I pass, including null. This works fine if I pass an 'eventRef', but never runs if that parm is empty.
Hi, Quick question on how SSIS handles queries from Data Source in a Data Flow. I noticed that when I run a particular query from Query Analyzer it takes forever. But, when I run the same query in SSIS data source in a data flow. The query results are immediate.
The query plan is already cached in SQL.
Is this just something which I am seeing incorrect or is there some bit of optimization in there in SSIS. As per my understanding SSIS does not optimize the source query.
Hi All, I'm trying to use a very simple SQL String that check if a specific string exist in the DB. When I do the SQL and use a regular Connection I get the result. When I use a data set and on the table adapter I need to use the "LIKE %" method I get an error.
What should I write on the table adapter in order to make this search?
ItemID is a type string.
This is my SQL: SELECT itemID, itemName FROM Items WHERE (itemID LIKE @ItemIDTemp)
This sample give no result or
SELECT itemID, itemName FROM Items WHERE (itemID LIKE '%' + @ItemIDTemp + '%')
This sample return an error message "Data conversion failed. [OLEDB status value (if known)=2]"
Hi,I have a table with uniqueidentifier column as its primary key. If I insert a record into this table by defining the key of this record in VB code (Dim myId As Guid = Guid.NewGuid ... is it??), is it possible that I receive the primary key violation error since the new record has an id which is already exists in the table? Thanks in advance
if in response to an alert i have defined a job and this job is scheduled for 10.00 am daily, will this job execute daily or only in response to the alert? also i have set notifications to my computer in alert as well as in job. buti get notification defined in job and not in alert. why is it so?
I have this 3 tables, Customer, Transaction and Book. Since a customer can buy the same book more than one time, I've defined Transaction_Nr as primary key of Transaction and put Customer_Nr and Book_Nr as foreign keys. So the layout is more or less like this :
So now my question is, would it have been better, to define Transaction_Nr, Book_Nr and Customer_Nr as a combined primary key or to leave Transaction_Nr alone ? What would be the difference ?
I'm trying to populate a DropDownList from my SQL database. I'm using C# 2005 and when I compile my code I get an error. Compiler Error Message: CS0103: The name 'myConnection' does not exist in the current context using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class Default3 : System.Web.UI.Page { private string connectionString = WebConfigurationManager.ConnectionStrings["mewconsultingConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e) { SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myCommand.CommandText = "SELECT * FROM tblPau"; myConnection.Open(); SqlDataReader myReader; myReader = myCommand.ExecuteReader(); myReader.Read(); // The first row in the result set is now available. lstPau.Items.Add(myReader["PauSiteName"]); myReader.Close(); myConnection.Close(); } }
I create my datasource to point to my local asmx and tested it by going directly to the URL which worked. I then create a dataset in my report which points to this datasource and has this as the query string:
Is there any harm in defining a SqlConnection as a private class variable for a web page?Private SqlConnection cn = new SqlConnectection(ConfigurationManager.ConnectionStrings["MyString"].ConectionString);The connection is only opened in certain event handlers, and is closed right after use. It was always my understanding that creating the connection is not a big deal but opening the connection is. Is that correct?
Can anyone help me understand what it takes to define a Linked Serverconnection to an IBM eSeries (AS400)? Do I need Microsoft's SNA Serveror some other product or can I simply do it with the tools provided withSQL Server 2000?Any guidance would be very appreciated. Thanks.Farid
I am new to SQL Server platform, i want to define primary keys automatically other than using an identity. For a table called indicator i want it primary keys to be like ind_001, ind_002, ind_003 and so on.
Can anybody help me on how to do this? I am new to this platform so i will appreciate it if suggestions are explained very clearly. Thank you
I have same table structures in two database and one master table which contains Table id, Table name,primary key, data type of primary key. i have to comapare Tables in both tha database and as per result i have to do insert,update or delete.
for that i have written query :
DECLARE @rowcount_mastertable FLOAT SET @rowcount_mastertable = (select count(*) from master_table)
SET @TABLE_NAME = (SELECT TABLE_NAME FROM MASTER_TABLE TABLE_ID = @COUNTER) SET @primary_key = (SELECT primary_key FROM MASTER_TABLE WHERE TABLE_ID = @COUNTER) SET @Primarykey_DATATYPE = (SELECT Primarykey_DATATYPE FROM MASTER_TABL WHERE TABLE_ID = @COUNTER)
--In below line i want to declare a variable and datatype should be same as what we got from master table so that i can use this @MAX_primary_key to fetch --max of primary key from table name where table id is 1 DECLARE @MAX_primary_key @Primarykey_DATATYPE SELECT @MAX_primary_key = MAX(@primary_key) FROM @TABLE_NAME WHERE TABLE_ID = @COUNTER
---But by running it i am getting error that "Incorrect syntax near '@Primarykey_DATATYPE'. and "Must declare the variable '@MAX_primary_key'.
I am pretty new to SQL Server 2005 and SSIS. I am trying to dynamically load files into SQL Server 2005 using files/paths contained in tables. I have a key table in my SSIS package that defines which files should be processed, some default values that will be associated with each file (ie CompanyKey and PeriodKey) and the file path (see below for example):
CompanyKey
PeriodKey
ProcessFlag
FileName
2
61
FALSE
2005TB200501.xls
2
62
FALSE
2005TB200502.xls
2
63
FALSE
2005TB200503.xls
2
64
TRUE
2005TB200504.xls
2
65
TRUE
2005TB200505.xls
2
66
TRUE
2005TB200506.xls
2
67
TRUE
2005TB200507.xls
2
68
TRUE
2005TB200508.xls
2
69
TRUE
2005TB200509.xls
2
70
TRUE
2005TB200510.xls
2
71
TRUE
2005TB200511.xls
2
72
TRUE
2005TB200512.xls
The package I am developing is supposed to loop through this table checking for files with ProcessFlag = TRUE. For those files, it will load all of the records/columns (prefaced with the company and period keys) into a common table.
Do I have to manually create data sources for each file or is there a way to dynamically define the connection and process the connection?
Any assitance you could provide would be greatly appreciated!
I'm assisting in the creation of a development enviroment with SQL Server 2005, and I need to assign some custom roles, in particular, a Stored Developer Role should be able to create, modify and execute Stored Procedures but they should not be able to alter tables or views, but should be able to retrieve/insert data from those tables.
I've tried with the default roles in 2005 to no avail.
Is there a relatively easy way to accomplish this with a database alredy populated with objects of both kinds? (SP's and Tables / Views)
Can someone verify that an assembly containing an interface with an event definition, such as...
public interface A { event EventHandler Foo; }
... can never be loaded under SAFE or EXTERNAL_ACCESS ?
It appears that the compiler-generated add_xxx and remove_xxx have the MethodImpl(MethodImplOptions.Synchronized) attribute defined by default, and "Explicit synchronization is not allowed". The same limitation also applies to classes by default, although technically one is able to define the implementation directly (clearly not ideal).
Hiii I am working on a application where I will upload my excel sheet.Then the application will read the header and will create a table to store the excel sheet. When the excel sheet will be uploaded first it will read the header of the excel and will display it inside a gridview to choose which columns are to be created along with datatype.I am giving u a snapshot
Column Name Select Datatype
Group Code
Emp No
Mem code
Amount
So Here the user is selecting tha data type.So I am passing the data type to my functions.But while assigning the datatype I am getting error that can no convert from sting to Microsoft.SqlServer.Management.Smo.DataType.I am giving u the demo codeprivate void button1_Click(object sender, EventArgs e) {ServerConnection objsvrconn = new ServerConnection(); objsvrconn.LoginSecure = false;objsvrconn.ServerInstance = "DEMO"; objsvrconn.Login = "sa";objsvrconn.Password = "sa"; Server objsvr;objsvr = new Server(objsvrconn); //objsvr.ConnectionContext.Connect();Table tb = objsvr.Databases["Demo"].Tables["Temp"]; Column c = new Column(tb, "GrpCode"); DataType dt = new DataType();dt.SqlDataType =(DataType)"Varchar" ---I am getting the error here.It only accecept from a enum i.e Datatype.Typename but doesnot accept like this dt.MaximumLength = 10; c.DataType = dt; tb.Columns.Add(c); tb.Alter(); }
I have an XML file that some of the nodes are represented with a namespace prefix. I have found the "msdn" page where shows the possibility to filter using the Namespace Prefix, but I have not been successful at it.
On first Node A: The server has 16 GB of physical RAM. On second Node B: The server has 10 GB of physical RAM.
Now, this being Active Active, Node A can be clustered on failure onto Node B..Now reporting server is configured under these two nodes, with defined MAX and MIN server memory of 12 as MAX and 0 is min IN GB.Now with this setting on SQL whenever the cluster moves, such config make OS goes low on node for 10 GB.I am only left with option of switching this MAX and MIN to a default setting or is there any other alternative such as script which can change this setting accordingly when cluster moves to respective server.
hi I have this asp sql statement which works fine but I want to use an spl adapter instead as I am enabling paging in details view. I am stuck in one place. How do I declare @listing as I have done in the select parameter in the asp sql statement? Where in ths sql adapter do i declare it? listing value is derived from a dropdown box when the user makes a selection. This is the sql statement i want to declare in the adapter.<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" SelectCommand="SELECT UserDetails.UserId, UserDetails.FirstName, UserDetails.LastName, UserDetails.City, aspnet_Membership.Email FROM UserDetails INNER JOIN aspnet_Membership ON UserDetails.UserId = aspnet_Membership.UserId WHERE Category = @Listing"> <selectparameters> <asp:controlparameter name="Listing" controlid="SearchListingDropDownList" propertyname="SelectedValue"/></selectparameters> This is the adapter so far which gives me an error to declare scalable value @listing. How do i incoporate the select parameters below? Function getTheData() As DataTable Dim DS As New DataSet() Dim strConnect As New SqlConnection(ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ConnectionString)Dim objSQLAdapter As New SqlDataAdapter("SELECT aspnet_Membership.UserId,UserDetails.FirstName + ' ' + UserDetails.LastName AS 'Customer',UserDetails.City, aspnet_Membership.Email FROM aspnet_Membership INNER JOIN UserDetails ON aspnet_Membership.UserId = UserDetails.UserId WHERE Category = @Listing", strConnect)objSQLAdapter.Fill(DS, "aspnet_Membership,UserDetails")
Return DS.Tables("aspnet_Membership,UserDetails").Copy End Function