SQL Server :: Writing A Conditional T-sql In Vb.net?
Dec 23, 2010How do I properly write an if statement for t-sql in vb.net?
I have this code:
[Code]....
How do I properly write an if statement for t-sql in vb.net?
I have this code:
[Code]....
This might be confusing but ill try to explain the best as i can. I have a gridview that get the data from datatable. This is simulation my grid view.
key data
1 data1
2 data2
2. data2
2. data2
3. data3
3. data3
what i want is make some conditional statement, when value "key" is changed i want to add empty row. so its suppose to be looks like this as result.
key data
1 data1
EMPTY ROW
2 data2
2. data2
2. data2
EMPTY ROW
3. data3
3. data3
I have a [Permission] and [Unit] table (permissions types are to view, update, add, ... records). One of the [Unit]'s is "1" for "ALL Units". What I want to do is use either a CASE or IF statement in my view which will pair every [UnitId] (except "1" ofcourse)
if/when the [UnitId] is set to "1".
Here are my view as-is:
[Code]....
Which results in: [Code]....
What I want is: [Code]....
this might be an easy one, but I just can't get it.I am creating a page which will query a table with many columns and most items are not unique. I need to be able to get a list of records that match as many of the (up to 4) search criteria as possible.Example:am user searching for the following items, I enter at least one and up to 4 of the items below in a text box:Name, age, gender, weight (user may or may not fill in all of them).If he just enters "F" for gender, then he will get a list of thousands of females with their name, age, gender and weight.However if he enters "F" for gender and "300" for weight, he will get a much smaller list of returned records.I need to be able to create a sql statement that can perform that search with that functionality.
View 6 RepliesHow to write a webservice to call the proxy server through IIS webserver?
View 2 RepliesI'm a little stuck here, with my first server control. I'll just post the whole thing, as I'm sure I've done plenty of mistakes. The main thing for me to find out is if there's a more elegang way to write this.
What I'm trying to accomplish here is to write a panel with custom HTML inside it. Inside the custom HTML, I need to put some server controls I can actually reach. My attempt at finding the span in the code failed, so there's obviously something wrong.
[Code]....
Obviously, I've only just begun, but I'd really value some feedback before I dig myself in too deep ;)
I have a package which imports several files on a regular bases . For the import I use a staging table. Now I want to split that stagingtable into two other (existing) tables with keeping the relation ( third table??) . In each record there is a dealerID which has to be injected also in the other two tables (the splittables).
How can I use a conditional split to extract the right columns to the right table? I only see that i can enter a expression for each column, but in fact i only want to split the table by "fingerpointing" the right columns. is that possible? And how should i put the relation between them in 'relation' table?
I have some problem in inserting the wholerow in mt database table at once.....I would like to explain it:i have a function as
public DataSet senddata()
{
........................... [code]...
Now I to insert this data into the database I have made in the same format(schema).I have a function like :
database name is ABC
tablename is XYZ
public void inserttodatabase()
{
DataSet ds= senddata();
I have write small web-service that recieves query and read txt file for matching. For it I'm using StreamReader.
I'm not waiting that it will be thousands of users in hour for this service, but whats worried me - if some users at the same time will be use that service is it ok? Can text file on server side be readed at same time from some users?
What is capacity for using StreamReader or StreamWriter on server?
I have an ASP.NET app that writes binary data to a SQL database. It worked fine using SQL Express, but does not ever write the data using SQL Server 2008 R2. SQL Profiler shows the binary data in the UPDATE query, but nothing happens... no errors, no data saved. Does anyone know what I'm missing? Other data types work fine.
My data type is VarBinary(MAX)...
I have a table that is not getting updated. My insert command is working fine. Here is the update code from business logic area and stored prodecure. The SP works fine when I execute it from sql mgmt studio and updates the table:
[Code]....
I have a new web application I'm trying to create. I'd like to put some automation into how it propagates upcoming dates. Here is the way I'd like it to function.
I have three tables:
Managers
- id
- netid
- phone1
- phone2
- username
Monthvals
- id
- monthname (Friendly like December 2010)
- monthval (shortdate like 2010-12-01 00:00:00)
Weekends
- id
- weekend_val (date of the friday)
- month_id (Monthvals.id)
- mgr_id (Managers.id)
The tables I need to create SPs for are monthvals and weekends that will build the upcoming year. This is where I'm kind of stumped.
The spec for this is each manager gets assigned a weekend every 35 days with the exception of two which alternate so in that case, every 70 days.
What I need this SP to do is based on the activity in December or the last six weeks, I'd like it to write out a schedule for the following year. I don't mind writing this out but I could really use some psuedocode to iron out what I'm trying to do.
I am trying to create and write a file on a remote server using the below code:
[Code]....
but i am running into issues and getting errors. Below are some tries i have given. My IIS settings are 'Anonymous Access' checked and also 'Integrated windows authentication' checked.
a. As i understand asp.net site would run using ASPNET account, i tried giving full permission to ASPNET account to the folder on the remote server (where i want to drop the file). But i am getting this error - "Logon failure: unknown user name or bad password"
b. The other thing i tried is giving full permissions to 'Everyone' to the remote server folder. But i get the same error as above. But when in my web.config i enable impersonation by using:
[Code]....
then the error goes away and everything works fine as expected. The file gets dropped to the network share.
why the scenario (a) doesn't work because that should work as if i give ASPNET account full access to the folder, and my website is running under the same account, then it should work.
Also, in the scenario (b), i believe it is using my domain account, as the impersonation is true without specifying any username and password and also the remote server folder has Everyone access to full control.
BUT, as a security breach, i cannot use Everyone account to the remote folder. In that case, how can i make this working.
I was also thinking if i can use the virtual directory as the path to the remote folder, something like
http://domain.com/remotefolder but dont know how can i use this approach. Can someone pls share some sample code and the configuration.
In Production Server there are Issue with Writing in one of File. File not getting Write.I have give all the permsion even added EveryOne give full permsion.It's working on a windows 7 But Not working on a Windows Server 2008.R there any extra permsion need to apply ??
View 1 RepliesI'm making an application which takes image from user upload it to server and then perform any image processing like to convert to gray or invert etc.
My problem is this when i did the process on image to gray it or invert then how to write this new file on server or is there any other way so that i would be able to show this (new) image to user and make it downloadable?
How to write and deploy SSIS data transfer packages. ?
View 2 RepliesI need some jquery code in my application I have a button on the page and I want to handle it by jquery when the user click on it to show a confirmation dialog for example Are you sure? yes|no buttons but this is an asp.net button inside the updatepanel and in the other side I have some server side code to delete a record from database but my question is how I can handle both of them? server side and jquery inorder to when "yes" button clicked it runs server side and delete recorde from database and if the button is no it stop running ?
View 1 RepliesI've got an MVC 2 application running on Server 2008 R2, IIS 7.5. The application runs without issues. I added ELMAH to trap unhandled errors, write them to a database and send emails. The ELMAH functionality works without issues on my development machine (XP). However, that same functionality does not work on the server. ELMAH fails silently so I'm at a loss to know why things are not working
View 2 Repliesi need to save multiple documents stored in SQL server as Image type to disk.
What i want to do is "backup" all files in a table (column) to disk, zip them and Response.TransmitFile(FilePath) to client.
I could use C# ot VB but that would require a lot of connections to database or a lot of server memory and i don't want that, becauze there are a lot of files to be saved Since SQL can write files to disk i was thinking about saving those files to disk directly from sql. Something like when u're doing a backup
[Code]....
I've created 2 web user controls. A = User control that displays an image, and B is the user control that hosts A. I'm trying to stream an array of bytes to A, but it seems like the Response.BinaryWrite method completely overwrites any heirachial controls (I can't see any of B's other controls besides the image).
How do I get A to just display the image from the byte stream? It doesn't come from a database, it's an image I created on the fly.
A's code:
[Code]....
I have the following table structure:
[code]....
The following query returns the default recordset:
[code]....
I am REALLY stuck with this and need a solution in the next 24 hours .i I have uploaded my asp.net web application to the web and have the database and connection strings functioning and reading the data from the database. But when I try to write to the DB
I get the following error :
Server Error in '/' Application.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
The wierd thing about this is the connection strings work from the local machine when I run from Visual Studio and I can write to the DB there, I just cannot write to the DB from the URL.
I am pretty new to asp.net but I am sure it has to be something to do with the web.config.
I use LINQ.But I can not add data twice "ZnizanaDnevnica.
How could you do one box:
tbl_dnevnice_obracun tbl_dnevnice_obracun = new tbl_dnevnice_obracun()
{ZnizanaDnevnica = ((totDiffHours> = 6 & & totDiffHours <8)? Convert.ToDecimal (dt.Rows [0] ['Znizana']. ToString ()): 0),((totDiffHours> = 12
& & totDiffHours <24)? Convert.ToDecimal (dt.Rows [0] ['Znizana']. ToString ()
I've got a weird problem: On a page, i've 2 updatepanels in conditional updatemode, with childrenastrigger set to true (default value).
A click on a IPostBackEventHandler control inside either the first or second updatepanel causes the 2 updatepanels to refresh.
I have an ASP.NET web app (with C#). In it I have a form with several fields and validators. For one of the validators I only need to validate when:
a certain textbox is empty and a certain record does not exist in the database (this is already handled).
I know I can't enable/disable the validator on page_load because something might be entered into that textbox. I also tried the following in the onclick event of the submit button but it didn't seem to work:
Validator1.Enabled = true;
Validator1.Validate();
I also tried Page.Validate() but that didn't work either...