|
// *** Setup DataAdapter with expicit INSERT, UPDATE,
// DELETE "Template" Commands.
private void InitializeCommands()
{
// Reuse the SelectCommand's Connection.
SqlConnection con =
(SqlConnection) _dataAdapter.SelectCommand.Connection;
// Create an explicit, reusable INSERT command
_dataAdapter.InsertCommand = con.CreateCommand();
_dataAdapter.InsertCommand.CommandText =
"INSERT INTO customers " +
"(CustomerId, CompanyName, ContactName, ContactTitle, " +
"Address, City, PostalCode, Phone) " +
"VALUES(@CustomerId, @CompanyName, @ContactName, " +
"@ContactTitle, @Address, @City, @PostalCode, @Phone)";
// Bind parameters to appropriate columns for INSERT command
this.AddParms(_dataAdapter.InsertCommand,
"CustomerId", "CompanyName", "ContactName", "ContactTitle",
"Address", "City", "PostalCode", "Phone");
// Create an explicit UPDATE command
_dataAdapter.UpdateCommand = con.CreateCommand();
_dataAdapter.UpdateCommand.CommandText =
"UPDATE customers " +
"SET CompanyName = @CompanyName " +
"WHERE CustomerID = @CustomerId";
// Bind parameters to appropriate columns for UPDATE command
this.AddParms(_dataAdapter.UpdateCommand, "CompanyName", "CustomerID");
|
|
|
|
|
hi
u did not get my doubt.
I have 3 webforms with two textbox each.in every form there is continue button except for last form where there is submit button.In the third webform when we click submit then all the webforms i.e firt,second and third data should go to database.continue takes to next webform.
After clicking submit ,if he feels he has given some wrong information in firt form,then he click back button in the browser and changes,then it should get updated
thanks in advance
riyasath
|
|
|
|
|
This is more of an ASP.NET question, and you should probably be storing the intermediate results from the first two forms in Session state.
|
|
|
|
|
hi
Thank's for ur reply.
iam new to .net.
can u plz explain the answer briefly.
my another doubt is by using dataadapter can we insert the data in database.?
My another question is by using dataset,where there is a emp table in it, and i want a denpno =10 whole record .how to get that complete record.
Thanks in advance
Byee
riyasath
|
|
|
|
|
Hi all,
I need to know what are my choices to implement the following:
I have a table named "PostedJobs" with a "Status" bit(Open/Close) field. When an Employer posts a job this bit field will be set to Open - on an Employer-chosen specific date this bit field will be set to Close. Then this job(row) must be deleted from "PostedJobs" and inserted into another table named "ClosedJobs" where I keep a log of old posts.
Now, is there any chance to automate the whole process?
Thanks in advance
|
|
|
|
|
If you are using SQL server you can use Sql Server Agent to periodically (say once a day at 00:00:1) run a job (stored procedure). The stored proc could check a table of Jobid/closeDate records and close out any jobs due for closure... if not SQL, then maybe use windows scheduler to run an exe that does the same thing(with or without a stored procedure).
|
|
|
|
|
Thank you very much Rob
|
|
|
|
|
Hey Rob,
I've scheduled a job in SQL Server Agent and created this step:
declare @ExpirationDate smalldatetime
select @ExpirationDate = min( ExpirationDate ) from PostedJobs where Status <> 'False'
while (select datediff (day, @ExpirationDate, getdate())) <= 0
begin
update PostedJobs set Status = 'False'
end
The problem is that when I tested it it executes successfully but it doesn't update rows that I set their date couple of days later.
Execuse me, this is the first time I use most of these tools.
thanks
-- modified at 21:06 Sunday 24th September, 2006
Altered the code to:
declare @ExpirationDate smalldatetime
select @ExpirationDate = min( ExpirationDate ) from PostedJobs where Status <> 'False'
while (select datediff (day, getdate(), @ExpirationDate)) <= 0
begin
update PostedJobs set Status = 'False' where PostedJobs.ExpirationDate = @ExpirationDate
select @ExpirationDate = min( ExpirationDate ) from PostedJobs where Status <> 'False'
end
worked fine
|
|
|
|
|
Is there a way of building an ADO Recordset from some data?
I need to return a Recordset structure from a function but the data is not available trough a database so the ideea was to load the recordset and return it. I want to do this because for some user settings my application cannot read data from a database and building my own recordset beats going trough all the code and reading settings. I can simply change the method that does the querying.
|
|
|
|
|
Hai friend,
You have to return a recordset from a function.
ur function
_Recordsetptr mRs;
mRs.CreateInstance(_uuidof(Recordset));
return mRs;
Ok try it
|
|
|
|
|
Hello,
I am creating a application that can connect any sql server on the network.
The customer would like a dialog box to be able to find a instance of a server, and then enter the password and username to get a list of all the database they want to connect to.
Does anyone have any examples projects in vb.net that does something like this.
I will be most grateful for any code.
Thanks in advance,
Steve
|
|
|
|
|
Hi Steve,
Refer the below link.
http://www.codeproject.com/cs/database/locate_sql_servers.asp
Regards
Narendra
|
|
|
|
|
Hi,
I was wondering when designing a database with multiple tables with PKs and FKs in place, why would I think to map those FKs and PKs between tables hence making relationships while I can retrieve whatever I need with joins without creating any relationships?
|
|
|
|
|
Hi
ADO.net Support you Option by GUI this help you to make relationships
and can make it by coding
|
|
|
|
|
Creating the relationships ensures database integrity.
If there is a relationship between table A and table B, where table A's PK is a FK in table B, then SQL server will not allow you to delete records in table A that has child records in table B.
I would not be surprised if there were not also performance benefits when joining table A and B aswell but I am not sure if this is the case.
|
|
|
|
|
You can get records using joins from any two tables. But if u are not using PKs and FKs how can u assure that a particular row or record in a child table is associated to a particular row in the master or parent table. By using PKs and FKs database forces a rule on data table so invalid data cannot be inserted.
Joins are used to fetch record from more than 1 tables but donot force the rules on datbase tables.
Do good and have good.
|
|
|
|
|
I need some help to find a solution for the problem. I have a VB6 application using ADO that needs to connect to a SQL Server Database with a UserID/Password for the secured database where the UserID/Password for the SQL Server access is different than the NT workstation Login ID and Password. The clients SQL Server is authorized for NT Authenication only and they will not allow SQL Authentication. Can this be done with ODBC? Or is there another method or can it be done at all? The environment is Server 2003, Active Directory, SQL Server 2000 and VB6 using ADO. Need help ASAP. Thanks..
flexTecs, Email Archive and eDiscovery Tool Development
|
|
|
|
|
1-add loging to SQL Server (windows logins from domain users)
2-use trusted connection in connection string:
"Provider=sqloledb;Data Source=SERVERNAME;Initial Catalog=DATABASENAME;Integrated Security=SSPI;"
|
|
|
|
|
OK, but does that me that I need to setup a group that I use in the Security Login on SQL Server and then have a user in that group that the Application uses and a user that is the Windows NT login. Remember I need the application to use a login that is the DBowner but the NT workstation login is a user. I would like to expand on this so that I clearly understand. So far the testing that we have done requires that the NT Workstation Login be the same as the SQL Login for the database. Thanks
flexTecs, Email Archive and eDiscovery Tool Development
|
|
|
|
|
For windows authentication to work as I described..Users must login to domain, not using a local machine login (You should setup an active directory).
|
|
|
|
|
You cannot do it at all. When using Windows Authentication, the identity of the thread is used to make the connection. You can only change the identity of a thread (to be different from the identity which the process is running under) using impersonation, but I'd really not like to try doing that with VB6.
|
|
|
|
|
I have a dataBase in Sql Server 2000 , and i want to connect to DataBase
I have crerated an conectionString by add connection in the server expolrer
(C#.Net Invironment) evry thing about connetion is correct but when program trying to connect DataBase an Exception occurs .
Exception Message is : Login failed for user 'Login1'.
Login1 is my login To DataBase registred in Security section of SqlServer 2000
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
Is the server configured for SQL Server authentication, Windows authentication or both (mixed)?
|
|
|
|
|
Hi all,
I've designed a database for a recruitment site, this is the my first time to design such a complex model, I feel that I have gone so far over-normalizing this database and made it too complicated. I need your comments/suggestions on its design. Please bear with me and I'll provide you with any details you might need.
An image of the database design model is here http://wunex.blogspot.com
|
|
|
|
|
Eliminate lookup tables that have only two or fewer choices (e.g. Gender). Military service - this is either yes/no or number of years - not a lookup
A lookup for Grades doesn't make sense - wouldn't this be a continuous range of values either a number (3.0) or a letter (A, B, C)?
Avoid "mapping tables" like Resumes_fields and Resumes_languages. In both cases, what is probaly wanted is
another tabel: Language_skills:(ResumeID,LanuageID,Language_proficiencyID), unless you really intend an n-to-m cross-reference (these can be difficult to maintain)
NoticePeriod does not seem like an attribute of a resume (rather a job-history) and should probably just be a range-limited value(0-n weeks) rather than a lookup.
|
|
|
|