|
Can anyone Help
I have Create the weekday table in sql server 2005.
Total three field is there in weekday table.
1)DayOfTheWeek
2)OfficeOpenHours
3)OfficeCloseHours
I have enter the value Sunday to Friday in DayOfTheWeek field.
I have set the primarykey in DayOfTheWeek field.
When i set the primary key its automatically set the value in ascending order format.
Before Set the Primary key in DayOfTheWeek field value
*******************************************************
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
After Set the Primary key in DayOfTheWeek field value
*****************************************************
Friday
Monday
Saturday
Sunday
Thursday
Tuesday
Wednesday
How to enter the sunady to Saturday value format with primarykey.
USE [checkweekday]
GO
/****** Object: Table [dbo].[weekday] Script Date: 04/28/2008 17:00:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[weekday](
[DayOfTheWeek] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OfficeOpenHours] [char](4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OfficeCloseHours] [char](4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_holiday] PRIMARY KEY CLUSTERED
(
[DayOfTheWeek] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
|
|
|
|
|
An easy solution would be to add a sequence column and order by that.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi everybody.
I have got some huge *.dbf files that a DOS based application updates them every minute
and also I want to use those files in a windows based application but there is a problem!
as I said my files are huge ( more than 5000000 records on each file ) and it takes a long time to read them with .NET ODBC driver. I think that if I link the files to SQLServer ( linked server ) and split them to small and usefull tables maybe it solves the problem. if it is possible say how can link the *.dbf files to SQL server ( Conection string, and other configuration ).Or are there any other solution? help me please!?
|
|
|
|
|
Hi,
I have a table with username and Registration number. I need to get the Registration number for the distinct usernames from the table.Can it be done using the "DISTINCT" query.?
|
|
|
|
|
Maybe. Why not try it and see?
Bob
Ashfield Consultants Ltd
modified on Monday, April 28, 2008 2:56 AM
|
|
|
|
|
I tried it , Since i can get only the Username , How to select the registration numbers from it? , Is there any other way to frame the query?
|
|
|
|
|
1. Post some samples from your table
2. Post your query
Then I will be able to help. If you have data like this:
Name Reg
M. Mouse 1
D Duck 2
then
SELECT DISTINCT Name, reg
from table
will do it.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
My Table entries are
Name Reg
M. Mouse 1
D Duck 2
L Lion 3
D Duck 4
M. Mouse 5
SELECT DISTINCT Name, reg
from table
This query gives the distinct combinations of name and reg not the distinct values for name . Since the combinations are unique all the entries will be returned .I need to get only Reg No's: 1,2,3
Any idea on How to frame the query for it?
|
|
|
|
|
here it is:
select distinct [name],<br />
(select top 1 a1.reg from myTable as a1 where a1.name = myTable.name order by a1.reg asc)<br />
from myTable
I Love T-SQL
modified on Monday, April 28, 2008 3:57 AM
|
|
|
|
|
Thanks for ur help,
Its working fine now..
|
|
|
|
|
You are welcome.
I Love T-SQL
|
|
|
|
|
If you are using SQL Server 2005, you should avoid subselects, because their performance is poor.
I'd rather use:
SELECT
NAME
, MIN(REG)
FROM dbo.MYTABLE
GROUP BY
NAME
|
|
|
|
|
thanks but your reply is not for me.
I Love T-SQL
|
|
|
|
|
When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks.
rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)<br />
Dim command As String<br />
<br />
<br />
command = "INSERT INTO Guest(Guest ID) VALUES('1111')"<br />
ADOConnection.Execute(command, rsGuest)
|
|
|
|
|
There are two possible reasons I can see.
Firstly, your syntax is wrong:
command = "INSERT INTO Guest(Guest ID) VALUES('1111')"<br />
Should be
command = "INSERT INTO Guest<big>[</big>Guest ID<big>]</big> VALUES('1111')"
Also, is [Guest ID] an identity (autonumber) column?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
column name Guest ID is having space so it cannot be used directly
use it like this
command = "INSERT INTO Guest([Guest ID]) VALUES('1111')"
Regards
KP
|
|
|
|
|
Sorry, thats what I meant - you need to put Guest ID in square brackets, I didn't mean to lose the () round it. Old age and failing eyesight to blame
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ok, I know vb.net and I've used ms access before and I understand the basic concepts of what a recordset and cursor and other stuff are but I have never used ADO before to program a database and I need to learn. Specifically I am trying to use vb.net 2005 to program ms access 2007.
I've opened the database and opened a recordset successfully. This is the code I used.
Private ADOConnection As New ADODB.Connection 'the database<br />
Private rsGuest As New ADODB.Recordset 'the recordset<br />
<br />
'code for opening the database and recordset<br />
ADOConnection.Open("provider=microsoft.ace.oledb.12.0;" & "Data Source=j:\junk.accdb")<br />
rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
What I need to know is what is the syntax for adding data to a recordset. If someone could give me an example it would be very helpfull. Thanks in advance.
Mike
ps I have googled the hell out of this but every example I find is either a different version of access or vb, or is an example of using sql server, or it is an example of vba within access. In any case there seem to subtle incompatabilities that mean the examples never seem to work.
|
|
|
|
|
check this[^]
I Love T-SQL
|
|
|
|
|
You really shouldn't be using ADODB from VB.Net. ADODB is an older COM technology and was replaced in .Net with the System.Data.Oledb namespace classes. Oledb uses Datasets, Datatables, DataReaders and DataAdapters rather than Recordsets. It performs better than ADODB and is easier to use, and is an integrated set of managed classes.
|
|
|
|
|
hello
I am new and i have just started learning sql 2005 and i have create small table student with 3 columns studentID,firstname and lastname it's works fine i can insert,delete without any problem but when i delete any antry it dosent refresh the page i mean it delete record from sql database but it shows deleted entry in text boxes but if i close application and restart it it dosent show deleted entry any help this is the code for delete
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click<br />
Dim SQL As String = Nothing<br />
SQL = "DELETE FROM Student WHERE StudentID = " & TextBox3.Text<br />
If MessageBox.Show("Are you sure you want to delete", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = MsgBoxResult.Yes Then<br />
conStudent = New Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\bablu\My Documents\Visual Studio 2005\Projects\SQL DataApplication\SQL DataApplication\Student.mdf;Integrated Security=True;User Instance=True")<br />
conStudent.Open()<br />
Try<br />
commStudent = New SqlClient.SqlCommand(SQL, conStudent)<br />
commStudent.ExecuteNonQuery()<br />
<br />
MsgBox("Itemdeleted successfully", MsgBoxStyle.Information)<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
conStudent.Close()<br />
conStudent.Dispose()<br />
Else<br />
Exit Sub<br />
End If<br />
End Sub
any help
waiting for your kind rep.
have a nice time
thanks
|
|
|
|
|
after you delete row then close and open connection
conStudent.Close()<br />
conStudent.Open()
for more information check this[^]
I Love T-SQL
|
|
|
|
|
hello
first of all thanks for your rep.
i have tried it but it's not working
this is the code
conStudent.Open()<br />
Try<br />
commStudent = New SqlClient.SqlCommand(SQL, conStudent)<br />
commStudent.ExecuteNonQuery()<br />
conStudent.Close() <------:confused:<br />
conStudent.Open() <------:confused:<br />
MsgBox("Item deleted", MsgBoxStyle.Information)<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
conStudent.Close()<br />
conStudent.Dispose()
is this what you are saying or some thing else
waiting for your kid rep.
have a nice day
|
|
|
|
|
hi ,
in try block after query exection just assign textbox.text="";
i think this solves u r problem .
if this is in webapplication we can set viewstate as false .
bye .
|
|
|
|
|
hello
thansk for your kind rep.
yes i have tried that before but it's not working well it's clear the text box but it also shows empty textbox when you move next or previous so i dont know what to do
still waiting for help
have a nice day
|
|
|
|