Saturday, August 15, 2020

How can connect Microsoft SQL Server 2014 into Visual Basic.net program?

 

 

Microsoft SQL Server 2014 into Visual Basic.net  
 
ആദ്യമായി Microsoft SQL Server 2014 open ചെയ്യുക,തുറന്നു വരുന്ന പേജിൽ 

 Server Type - Database Engine 
 Server Name - (eg:-.................\SQLExpress ) ഇതുപോലെ ഒരു name ഉണ്ടാകും. 
 Authentication -  server connect ചെയ്യാൻ രണ്ട് തരം Authentication കാണാൻ സാധിക്കും. നമുക്ക് വേണ്ടത് 2 authentication ആണ്. 
 1.window authentication
 2.Sql server authentication (select  ചെയ്താൽ Login name and password enter ചെയ്യാൻ ഉള്ള space കാണാം )



 
But നമുക്ക്  2 Authentication ഇല്ലെങ്കിൽ. 👇
 
Sql server authentication എങ്ങനെ ഉണ്ടാകാനുള്ള step by step
1. മുകളിൽ കാണുന്നപോലെ window  authentication select ചെയ്ത് conncet ചെയ്യുക. 
 
2. തുറന്നു വരുന്ന window ൽ Object Explorer ൽ Security എന്ന് പേരിൽ ഒരു folder കാണാം അതിൽ Login ൻറെ   right mouse ക്ലിക്ക് ചെയ്താൽ    New -login ക്ലിക്ക് ചെയ്യുക. 
 
 
 
3. Login page ൽ          login name and password with confirm password  type ചെയ്ത്
 
 സൈഡിൽ കാണുന്ന server roles ൽ ക്ലിക്ക് ചെയ്യുക public ☑️ ഉണ്ടാകും അതുപോലെ sysadmin ☑️ ചെയ്യുക.  Ok ക്ലിക്ക് ചെയ്യുക.


4. നമ്മൾ ഉപയോഗിക്കുന്ന Microsoft SQL Server തത്കാലം Stop ചെയ്യാൻ Services open ചെയ്യണം. അതിന് വേണ്ടി Control Panel---Administrative Tools ---Sevices ഓപ്പൺ ചെയ്യുക. 
 

 
അല്ലെങ്കിൽ 
(Window button ൽ press ചെയ്താൽ Computer ന്റെ right mouse ക്ലിക്ക് ൽ Manage ക്ലിക്ക് ചെയ്ത്, yes ക്ലിക്ക് ചെയ്യുക. അതിൽ കാണുന്ന Service and application )ൽ 
 
Service open ചെയ്ത്, തുറന്നു വരുന്ന list ൽ  SQL Server Express പേരിൽ  right mouse ക്ലിക്ക് ചെയ്ത stop ക്ലിക്ക് ചെയ്യുക. 
 
5.  നമ്മൾ ഉണ്ടാക്കിയ Sql server authentication
 ഉപയോഗിച്ച് server connect ചെയ്യാൻ 
 Object explorer ൽ connect എന്നതിൽ ക്ലിക്ക് ചെയ്താൽ അല്ലെങ്കിൽ Microsoft SQL Server 2014 ഓപ്പൺ ചെയുമ്പോൾ വരുന്ന window വരും അതിൽ നമുക്ക് 2 മത്തെ authentication (മുകളിലെ പറന്നത് നോക്കുക )
 
 Login name and password type ചെയ്ത് 
 Connect എന്ന് button കാണാം അതിൽ ക്ലിക്ക് ചെയ്താൽ Microsoft SQL Server open ആകും.  (Error  വരും അതിന് 4. Step ൽ പറഞ്ഞ services ൽ പോയി അത് restart ചെയ്യാണം )
 

 
  
 
 MS SQL server 2014 ൽ ഒരു Database with table മുകളിൽ ലെ link ൽ പറഞ്ഞത് പോലെ നിർമിക്കുക. 
 
 
 Microsoft Visual basic 2010 express ഓപ്പൺ ചെയ്തതിന് ശേഷം project tab ൽ add module select ചെയ്യുക. 


അതിൽ താഴെ കാണുന്ന code type ചെയ്യുക. 

 
 അതിൽ  MS Sql server മായി connect ചെയ്ത code താഴെ കാണുന്നത് 
conn.ConnectionString = "data source =DELL-PC\SQLEXPRESS;initial catalog= abc; user= aliza;password=61655616" 
 
 
അതിൽ 
data source =DELL-PC\SQLEXPRESS;
(Server name)
user= aliza; (Login name)
password=615516"(login password )

 
initial catalog= abc (database name)
 
  Form 1 ൽ ഉപയോഗിച്ചിട്ടുള്ള controls 
DataGridView 
3 Label 
3 Textbox
3  Button 
 

Form 1 ൻറെ code ൽ താഴെ കാണുന്നത് type ചെയ്ത് 



Run ചെയ്താൽ ഇതുപോലെ കാണാം. 



Microsoft Sql server ൽ Visual basic.net source code ൽ ഉപയോഗിച്ച table ൻറെ right mouse ക്ലിക്ക് ൽ Edit Top 200 Rows എന്നതിൽ ക്ലിക്ക് ചെയ്താൽ Visual basic കാണുന്ന പോലെയുള്ള datas കാണാം. 
Insert, update, detetion എല്ലാം Microsoft Sql server ലെ database മാറ്റപെടുന്നതായിരിക്കും. 



No comments:

Post a Comment