-
I've just started learning this!
-
'1 Connect to the database (using commands).
dim constr as string = "constr").connectionstring
dim constr as string = "data source=.;initial catalog=hotel;persist security info=true;user id=sa;password=123456"
dim con as sqlconnection = new sqlconnection(constr)
dim sql as string = "select * from userdetail where username='" & strname & "' and userpwd='" & strpwd & "'"
2 Create Command.
dim cmd as sqlcommand = new sqlcommand(sql, con)
3 Open the connection.
4 Execution. dim reader as sqldatareader =
5 Access. if then
msgbox(reader(0) &reader("userpwd"))
reader("userpwd"))
elsemsgbox("Query failed! Wrong username or password! ")
end if
6 Close. dim sql as string = "select * from userdetail where username=@name and userpwd=@pwd"
dim p1 as sqlparameter = new sqlparameter("@name", name)
dim p2 as sqlparameter = new sqlparameter("@pwd", pwd)
dim reader as sqldatareader = , p1, p2)
-
I used to use vs2008, and now I use 10, and I haven't used 05, but I think it should be about the same.
You can create a new database connection.
-
First of all, you should establish a connection in the file, and if you are building a three-tier architecture, then you will use the connection string sqlconnection connection=new sqlconnection() when operating the database at the dal data access layer"server=.;uid=sa;database=db") ;
-
using system; using ; using ; using ; using ; using ; using ; using ; using ; using ; public partial class _default : finally if(conn!=null) } I got it for you with my phone, and you can see if the brackets match or not.
There are some details that you have to change yourself. If you try to connect, you need to open SQL Server first and make sure that there is a database db in it. If the connection fails, you detach the db database, copy it to your c project directory, and try again.
-
If it's not too demanding, use the built-in gridview control to import it, under the data item in the toolbox. GridView can use smart tags (triangle in the upper right corner, click down to come out of the menu), step by step to take you to the database. See.
-
Let's use a statement. create table table name.
Field Name Class Bend Blind Type (Length) Whether it is empty Whether it is buried in the ear empty or whether it is the primary key.
For example: clan luck.
create table a
b varchar(2) null
-
Post the error message and see.
What is the specific reason for the failure: Remote access is not allowed?
-
If it turned out to be good, but now it doesn't work, it is generally the password that has expired, and if it is the first time, it is your setting problem.
-
SQL Server 2005 Express is included with Visual Studio installed
-
The default value is not the value that is automatically set when a null value is inserted, but the default value is automatically set when the field is not assigned (note: the system does not use the default value even if the assignment is null).
For example, see the table user info(user id, user name).
Suppose the default value of user name is'abc'
Suppose there is textbox1 and textbox2 on the interface, which are used to enter user ID and user name, respectively
The author expects textbox2 to have no input value when the field user name is'abc'?
If your sql="insert into user_info(user_id,user_name) values('" +
Then the value of the user name of textbox2 in the actually inserted record is null;
The following SQL allows the system to use the default values.
sql="insert into user_info(user_id) values('" +
-
In the process of insertion, you don't care about the fields with default values, you only need to insert other fields, and the default values are automatically generated.
-
This is what I think is this, just like the first floor said, you don't have to deal with this field in the SQL statement, so you can enable the default value, but if you use SQL to process this statement, the good thing is that the result of your SQL statement is the final knot, because the default value has been removed by your SQL statement, figure this out first to see that first execution, that later execution, of course, the result is the later execution.
Try to capture the return value.
Author: Xiao Kuan] private void restore().
string path = recovery path. text;Obtain the backup path and database name. >>>More
1.Create a socket
2.Determine the local computer endpoint (IP and port number). >>>More
with"connstr"Try it.
The complete one is"connstr"] >>>More